CaiJimmy / hugo-theme-stack

Card-style Hugo theme designed for bloggers
https://stack.jimmycai.com
GNU General Public License v3.0
4.89k stars 1.6k forks source link

Favicon does not load if baseurl includes a subfolder #922

Closed delize closed 9 months ago

delize commented 9 months ago

What happened?

When trying to use a baseurl that includes a subfolder, for example: baseurl: http://localhost/blog/

And setting favicon: /favicon.ico, the favicon fails to load on any page, as it isn't following the subfolder within the base url.

image

Now, if we alter favicon: /favicon.ico to favicon: favicon.ico this now works for the main page of http:/localhost:1313/blog.

image

However, once we go to a blog post (for example, the ones included in the example config) or any page that isn't the root post.

image

The favicon fails to load again.

I believe the line items https://github.com/CaiJimmy/hugo-theme-stack/blob/21da06e448fe466ef0a03d1c717847f0eb0049fe/layouts/partials/head/head.html#L21-L23 Needs improvement, but, I am not sure what as I am not super familiar with Hugo (I'm currently transitioning from Jekyll, and thought your template was really nice. Great job!) If I modify this line and statically list /blog/favicon.ico, everything works as intended.

This is when the theme is loaded as a submodule in hugo.

Hugo version

v0.121.1-00b46fed8e47f7bb0a85d7cfc2d9f1356379b740+extended darwin/arm64 BuildDate=2023-12-08T08:47:45Z VendorInfo=brew

Theme version

v3.21.0

What browsers are you seeing the problem on?

Chrome

More information about the browser

macOS Sonoma 14

Relevant log output

No log output, as there is no error starting hugo server. 

Images for failed file load in original issue.

Link to Minimal Reproducible Example

N/A - repo is currently private while I try and transfer over posts from jekyll

delize commented 9 months ago

What does work is inputting: /blog/favicon.ico

However, if the base url includes a subfolder, this is slightly confusing, as the subfolder in the favicon yaml file should not need /blog/.

delize commented 9 months ago

I may be wrong, but, after reading: https://gohugobrasil.netlify.app/functions/absurl/

I believe that the line above needs to be changed from . to . | relURL

CaiJimmy commented 6 months ago

I may be wrong, but, after reading: https://gohugobrasil.netlify.app/functions/absurl/

I believe that the line above needs to be changed from . to . | relURL

Hi @delize, thanks for pointing this out. Would you like to create a pull request for this issue?

delize commented 6 months ago

PR opened up above @CaiJimmy

I do have a FR issue that I have been meaning to submit, but, will get around to that when I can. I haven't found a good implementation of the FR into the blog when trying to accomplish it yet.