theNewDynamic / gohugo-theme-ananke

Ananke: A theme for Hugo Sites
https://gohugo-ananke-theme-demo.netlify.com/
MIT License
1.1k stars 1.13k forks source link

Ananke theme - featured images not displayed when baseURL includes subdirectory #556

Closed robexley closed 2 years ago

robexley commented 2 years ago

See the following post on Hugo discussion forum => https://discourse.gohugo.io/t/ananke-theme-featured-images-not-displayed-when-baseurl-includes-subdirectory/38963

--

I am using Hugo v0.100.1+extended installed using homebrew on Mac with the ananke theme. I’ve setup the structure to use page bundles and have images showing correctly when embedded inline in a post. I am struggling with the featured images on post content.

I’m able to display a featured image for pages if the image is in the static/images folder and referenced via an absolute url (i.e. ‘/images/exampleImage.png’)+

but I’m unable to display any featured images stored within the page bundle using a relative url (e.g. ‘exampleImage.png’ or ‘./exampleImage.png’)

This may also be related to the fact that my site is using an additional path element within the baseURL, e.g. baseURL = ‘site.hostname/project’ so when then url is generated when using a relative URL is “http://localhost:1313/project/project/posts/2022/03/24/exampleImage.png” note: the duplication of ‘project’ in the generated URL

regisphilibert commented 2 years ago

Hi could you share a link to your repo?

Thanks a ton!

robexley commented 2 years ago

Hi Regis, See the following https://discourse.gohugo.io/t/ananke-theme-featured-images-not-displayed-when-baseurl-includes-subdirectory/38963/3?u=robexley where Joe Mooring created a specific project in his GitHub repo to illustrate the issue.

regisphilibert commented 2 years ago

Hi @robexley and thanks for reporting this. I implemented a fix on this branch: https://github.com/theNewDynamic/gohugo-theme-ananke/pull/557

Would you mind testing it by either checking out its latest commit (if you're using the theme as a submodule) or upgrading the Hugo Module to it if you're using Hugo Modules by doing:

hugo mod get -u github.com/theNewDynamic/gohugo-theme-ananke@b89cd62afb84dd00e7eebfc7d7c13e4b8dcd59b7

Let me know if this works I tried it in our own sandbox.

robexley commented 2 years ago

Hi @regisphilibert , Thanks for that. I've checked out the proposed fix on branch '556-featured-bundle-fix' and tested it using the test case provided by @jmooring and also using my original project site. Both work correctly with your fix - good news!