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

Can't add favicon #237

Open
kiyubits opened this issue Sep 26, 2024 · 13 comments
Open

Can't add favicon #237

kiyubits opened this issue Sep 26, 2024 · 13 comments

Comments

@kiyubits
Copy link

Hi i'm having issues with adding my own favicon

I've tried adding the favicon to the static folder static/favicon.ico but it isn't showing

I tried looking at the example config.toml and it doesn't mention the favicon location, it leads me to believe that simply adding the favicon files in the static folder will make the favicon show after publishing (i think?), but that hasn't worked for me

Adding my own images (like an avatar) worked though, with my hugo.toml file having

avatarURL = "images/avatar.jpg"

(for some reason putting a "/" before images doesn't work for me), but the same thing with favicon = ... doesn't work

much appreciated :D

@yashmehrotra
Copy link
Collaborator

@kiyubits Can you share a screenshot of your browser network tab which shows the request for the favicon, it's path and http status code

@jamesericdavidson
Copy link
Contributor

jamesericdavidson commented Sep 27, 2024

It looks like requesting any resource in your static/ directory results in 404, even when served locally.

Your repo is composed in an interesting way (no submodule, for instance?) gh doesn't recurse submodules by default, oops!

@kiyubits After testing locally, I believe this is related to your baseURL:

baseURL = "https://kiyubits.github.io/kiyubytes/"

Specifically, /kiyubytes/ is interfering with relative and absolute paths. Relating to your earlier point:

(for some reason putting a "/" before images doesn't work for me), but the same thing with favicon = ... doesn't work

When I set the following baseURL, requesting the favicon.ico (and other static/ resources) results in HTTP 200:

baseURL = "https://kiyubits.github.io/"

@jamesericdavidson
Copy link
Contributor

Earmarking for future reference: #79 and #129 may be related.

@kiyubits
Copy link
Author

So is the simple solution just changing the domain name to remove the sub directory /kiyubytes/ from the base URL?

Also, the avatar.jpg is called correctly on the home page and displays correctly, but when I go into the post it doesn't work and calls from the wrong location:

GET https://kiyubits.github.io/kiyubytes/posts/first_post/images/avatar.jpg 404 (Not Found)

avatar.jpg is not in the posts directory, its in static so that's acting strange.

Also I'm not sure how to find the favicon in the browser network tab, how are favicons added using this theme? (I couldn't get a clear picture from the documentation)

@jamesericdavidson
Copy link
Contributor

So is the simple solution just changing the domain name to remove the sub directory /kiyubytes/ from the base URL?

Yes.

Also, the avatar.jpg is called correctly on the home page and displays correctly, but when I go into the post it doesn't work and calls from the wrong location:

GET https://kiyubits.github.io/kiyubytes/posts/first_post/images/avatar.jpg 404 (Not Found)

avatar.jpg is not in the posts directory, its in static so that's acting strange.

I suspect this is related, and can be solved as above.

@jamesericdavidson
Copy link
Contributor

Also I'm not sure how to find the favicon in the browser network tab, how are favicons added using this theme? (I couldn't get a clear picture from the documentation)

@kiyubits

Network tab

On Firefox, press F12 and go to the Network tab (Chromium browsers should be similar):

image

Favicons

The documentation is here: https://gokarna-hugo.netlify.app/posts/theme-documentation-basics/#favicons-browserconfig-manifest

For example, my static/ directory looks like this:

image

@jamesericdavidson
Copy link
Contributor

@kiyubits Do you want to try my solution? It'd be great to have another data point to base further investigation/documentation on. 🙂

@kiyubits
Copy link
Author

kiyubits commented Oct 5, 2024

Hey sorry I've been a little busy the past few days, but yeah I plan to recreate the whole repo but with the baseURL that you mentioned, and I'll see if that resolves the issues. If it does work then it would be nice if the documentation added a note that having a subdirectory as part of the baseURL might cause these kinds of issues :)

@jamesericdavidson
Copy link
Contributor

jamesericdavidson commented Oct 5, 2024

Great! I noted here that similar issues have been lodged in this repo, so there may be a deeper cause which has gone unidentified; Hugo's own documentation defines a baseURL similar to your own.

N.B. You can change your default branch (and re-write the Git history, if you wish), or change the baseURL in one commit. I don't know how that affects GitHub pages. Best of luck 😁

@pkierski
Copy link
Contributor

pkierski commented Oct 13, 2024

As a workaround you can add something like:

    <link rel="icon" href="/blog/favicon.ico">

to customHeadHTML parameter in configuration. <link rel="icon" ...> takes precendence over default /favicon.ico. Here is more about favicons and ways for adding it to the page.

@jamesericdavidson
Copy link
Contributor

jamesericdavidson commented Oct 14, 2024

The favicon 404 is one symptom of a misdeclared baseURL, other issues present themselves (such as navigation completely breaking on the local server)

@jamesericdavidson
Copy link
Contributor

@kiyubits Howdy 🤠 have you made progress?

@kiyubits
Copy link
Author

kiyubits commented Nov 2, 2024

hi i'm sooo sorry but i haven't worked on it at all since then, but i think i'm already pretty satisfied with the responses here so its okay if this issue is closed :)

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

4 participants