Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Can you set caption for cover image? #17

Closed
singhkays opened this issue Oct 4, 2020 · 11 comments
Closed

[Feature] Can you set caption for cover image? #17

singhkays opened this issue Oct 4, 2020 · 11 comments

Comments

@singhkays
Copy link

I'd like to set the following caption for the cover image

<span style="margin:-20 0 0 0; display:block; text-align: center;"><i><small>Photo by <a href="https://unsplash.com/@birminghammuseumstrust?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Birmingham Museums Trust</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></small></i></span>

Here's an example from another theme - https://minimo.netlify.app/docs/cover-image/

---
cover:
  image: /images/eden-farm-children-s-village.jpg
  alternate: Picture of a yellow wall with a blue window in the upper-left corner
  caption: Eden Farm Children's Village by Gareth Harper on Unsplash
  style: full
---
@adityatelange
Copy link
Owner

According to my perspective the theme is minimal and adding a caption to cover post hinders it's flow, it just looks great without the caption.

Try imagining a caption below the cover image, what do you feel will it look great ? Let me know.

image

@singhkays
Copy link
Author

The reason I want to set a caption in this case is for attribution. I would be ok with another way to do this but the first piece of text in the markdown file is rendered after the TOC. If there was a way to render the text before the TOC, I think that could work.

@adityatelange
Copy link
Owner

The reason I want to set a caption in this case is for attribution. I would be ok with another way to do this but the first piece of text in the markdown file is rendered after the TOC. If there was a way to render the text before the TOC, I think that could work.

Noted.

adityatelange added a commit that referenced this issue Oct 4, 2020
* shown only on single page

usage =>
in page-vars front-matter

cover:
  image: '<image path/url>'
  alt: '<alt text>'
  caption: '<text>'
@singhkays
Copy link
Author

@adityatelange I see the new cover format in the commit. When I updated the theme with this new commit, the site build started failing with the following error. Looking at the file, will you only support the new format or maintain backward compatibility with existing format (cover: "<image-path>") as well?

hugo server -D
Start building sites …
ERROR 2020/10/04 10:51:55 render of "page" failed: "/Users/k/Documents/singhkays/themes/hugo-PaperMod/layouts/_default/single.html:29:16": execute of template failed: template: _default/single.html:29:16: executing "main" at <.Params.cover.image>: can't evaluate field image in type string
ERROR 2020/10/04 10:51:55 render of "page" failed: "/Users/k/Documents/singhkays/themes/hugo-PaperMod/layouts/_default/single.html:29:16": execute of template failed: template: _default/single.html:29:16: executing "main" at <.Params.cover.image>: can't evaluate field image in type string
ERROR 2020/10/04 10:51:55 render of "page" failed: "/Users/k/Documents/singhkays/themes/hugo-PaperMod/layouts/_default/single.html:29:16": execute of template failed: template: _default/single.html:29:16: executing "main" at <.Params.cover.image>: can't evaluate field image in type string
ERROR 2020/10/04 10:51:55 render of "page" failed: "/Users/k/Documents/singhkays/themes/hugo-PaperMod/layouts/_default/single.html:29:16": execute of template failed: template: _default/single.html:29:16: executing "main" at <.Params.cover.image>: can't evaluate field image in type string
Built in 451 ms
Error: Error building site: failed to render pages: render of "page" failed: "/Users/k/Documents/singhkays/themes/hugo-PaperMod/layouts/_default/single.html:29:16": execute of template failed: template: _default/single.html:29:16: executing "main" at <.Params.cover.image>: can't evaluate field image in type string

@singhkays
Copy link
Author

singhkays commented Oct 4, 2020

So I got it working by temporarily removing all past content out of the content directory. If I understand correctly, the issue is that this would require me to change all the previous posts with older cover formats to the new format which is quite a task 😢

Follow up asks

  1. Would it be possible to support both styles of cover formats?
  2. Is it possible to add a hyperlink to paths specified in the cover path or does Hugo restrict this?

@adityatelange
Copy link
Owner

  1. I don't feel it is needed. It's a one time task(if you continue to use papermod), to replace with newer format, just as it is less confusing, make sure you're using yml for easier syntax

  2. not with current code, can be enabled (one liner )

@singhkays
Copy link
Author

  1. To do this change across 100s of previous files is probably going to take some sort of scripting. I suppose others migrating from different themes might run into the same issue. It might be better if you added an if check to support the alternate format as it seems to be common for other themes. Therefore, rather than failing builds for people migrating it might be better to support what exists rather than force a disruptive change.
  2. Do you mean override the partials template? What doc should I look at for more info?

@adityatelange
Copy link
Owner

force a disruptive change.

#17 (comment) your original issue had this kind of format, don't blame me if you don't like it

@singhkays
Copy link
Author

force a disruptive change.

#17 (comment) your original issue had this kind of format, don't blame me if you don't like it

Don't get me wrong, I'm not laying blame on you. Very thankful for the support so far but after thinking through this more what I'm outlining is a potential problem your users might find themselves in as they migrate from other themes.

adityatelange added a commit that referenced this issue Oct 5, 2020
 * allows users to add links and stuff #17
@adityatelange
Copy link
Owner

  1. Do you mean override the partials template? What doc should I look at for more info?

just use markdown to add links now d0c7635

@singhkays
Copy link
Author

This works, thank you!

Wonderfall added a commit to Wonderfall/hugo-WonderMod that referenced this issue Jul 23, 2022
kylethedeveloper pushed a commit to kylethedeveloper/hugo-PaperMod that referenced this issue Feb 21, 2023
* shown only on single page

usage =>
in page-vars front-matter

cover:
  image: '<image path/url>'
  alt: '<alt text>'
  caption: '<text>'
kylethedeveloper pushed a commit to kylethedeveloper/hugo-PaperMod that referenced this issue Feb 21, 2023
 * allows users to add links and stuff adityatelange#17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants