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

featuredImg not generating relative paths after recent change #29

Closed
zemien opened this issue Jan 6, 2019 · 5 comments
Closed

featuredImg not generating relative paths after recent change #29

zemien opened this issue Jan 6, 2019 · 5 comments

Comments

@zemien
Copy link

zemien commented Jan 6, 2019

Commit 1e17ccb somehow changed the behaviour of featuredImg so that it's no longer referencing relative paths correctly. Have a look at my page New Year, New Beginnings and see the developer console.

It is trying to load the featuredImg from https://www.coderfrontline.com/city-night-explosion-firework.jpg rather than https://www.coderfrontline.com/new-year-new-beginnings/city-night-explosion-firework.jpg.

My folder structure:

-- content
---- posts
------ 2018-12-30-new-year-new-beginnings
-------- index.md
-------- city-night-explosion-firework.jpg
-------- (other image files used in the post)

My front matter:

title: New Year, New Beginnings
date: 2018-12-31T09:00:00+13:00
featuredImg: city-night-explosion-firework.jpg
categories:
  - General

I used git bisect to determine that it started happening with commit 1e17ccb but I don't know enough about Hugo templates to advise the exact cause.

Appreciate your good work - love the template!

@Track3
Copy link
Owner

Track3 commented Jan 7, 2019

I recently add that absURL function so the url of featuredImg will be processed by Hugo to make it absolute, it seems Hugo doesn't handle it right when images are in content folder. Maybe it's a good idea to leave it as is.

Track3 added a commit that referenced this issue Jan 7, 2019
@zemien
Copy link
Author

zemien commented Jan 7, 2019

  1. Do you think this is a bug in Hugo itself? OR
  2. You are having issues when navigating relative paths, i.e. "../../some-img.jpg"?

I have other images in that folder, which I included in my post using the figure shortcode (you can see the images in my blog post) which Hugo generated as expected.

It's not a big deal to leave it as is. Would you consider writing short Release Notes when you release a version, especially breaking changes, so existing users know what they need to update before getting latest? Thanks!

@Track3
Copy link
Owner

Track3 commented Jan 8, 2019

I didn't know you can put images in content folder to be honest, I assume people put images under the static folder. What that absURL function does is they take a string and parse them with site's baseURL. In this situation, they don't care where the image is actually located, the only thing they can see is that string. I don't know why I'm so tempted to use absURL, maybe I thought relative urls in inline css could cause problems, and as you can see, if images are in static folder or they are external, everything is fine.

After the recent theme update, You can use images instead of featuredImg, images is already used in Hugo internal templates, so it's more convenient to set up something like Twitter Cards or Facebook Opengragh. You can see the example post here: https://themes.gohugo.io//theme/hermit/posts/post-with-featured-image/. I didn't remove the featuredImg field, in case you don't need those meta tags. Same thing happened with that bgImg field, you can set homepage background image with images in site's config.toml.

Internal template also use absURL function so if you put images in content folder and set frontmatter with images, this will also produce incorrect image urls. But that's another issue to fix. I think for now, leave the featuredImg url untouched is fine.

I totally didn't expect this to be a breaking change, but I will try to make my release notes as detailed as possible.

@zemien
Copy link
Author

zemien commented Jan 8, 2019 via email

@Track3
Copy link
Owner

Track3 commented Jan 10, 2019

Yeah, I agree with you, Hugo is really flexible, you can manage content however you like, and it's hard for a theme to take care of all scenarios. As for donation, it's fine, thank you for your support, I'm more than happy to see people actually using my theme, that's enough for me.

@Track3 Track3 closed this as completed Jan 10, 2019
aliavni pushed a commit to aliavni/hermit that referenced this issue Feb 25, 2019
aliavni pushed a commit to aliavni/hermit that referenced this issue Feb 25, 2019
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