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

[BUG] favicon's links not match the full baseURL #1366

Open
novrain opened this issue Dec 26, 2023 · 4 comments
Open

[BUG] favicon's links not match the full baseURL #1366

novrain opened this issue Dec 26, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@novrain
Copy link

novrain commented Dec 26, 2023

Describe the bug
favicon's links not match the full baseURL

  • Hugo Version : 0.112.1
  • Theme Version : latest

Steps to reproduce the behavior:

build with baseURL param.

hugo --gc --baseURL http://a.com/base

index.html:

<link rel="canonical" href="http://a.com/base/">
<link crossorigin="anonymous" href="/base/assets/css/stylesheet.423bd960c236740ff23ffa9df8188a5393264504058af5c3c9414fd4643be13b.css" integrity="sha256-QjvZYMI2dA/yP/qd&#43;BiKU5MmRQQFivXDyUFP1GQ74Ts=" rel="preload stylesheet" as="style">

<!--wrong url prefix, should be http://a.com/base/assets/favicon.ico -->
<link rel="icon" href="http://a.com/assets/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="http://a.com/assets/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="http://a.com/assets/favicon.ico">
<link rel="apple-touch-icon" href="http://a.com/assets/favicon.ico">
<link rel="mask-icon" href="http://a.com/assets/favicon.ico">


<meta name="theme-color" content="#2e2e33">
<meta name="msapplication-TileColor" content="#2e2e33">
<link rel="alternate" type="application/rss+xml" href="http://a.com/base/index.xml">
<link rel="alternate" type="application/json" href="http://a.com/base/index.json">
<link rel="alternate" hreflang="en" href="http://a.com/base/">
<link rel="alternate" hreflang="zh" href="http://a.com/base/zh/">

Expected behavior:
favicon's link should match the baseURL

@novrain novrain added the bug Something isn't working label Dec 26, 2023
@novrain
Copy link
Author

novrain commented Jan 10, 2024

@adityatelange
Sorry to make you confused.

I mean if I set the baseURL to be http://a.com/base, the following part of html pages generated by paperMod:

<link rel="icon" href="http://a.com/assets/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="http://a.com/assets/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="http://a.com/assets/favicon.ico">

should be:

<link rel="icon" href="http://a.com/base/assets/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="http://a.com/base/assets/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="http://a.com/base/assets/favicon.ico">

Cause sometimes, there are multi-sub-sites under the same domian in sub directories.

root-
       -siteA
       -siteB

@ahogen
Copy link

ahogen commented Aug 15, 2024

favicon's link should match the baseURL

Maybe this wording is what confused the other user, but I get what you mean. The favicon URL should be relative to or based on baseURL, which may have any number of paths after the FQDN.

I encountered this as well with Git Lab Pages because the base URL is of the form https://<username>.gitlab.io/<project>/.

@GiacomoCortesi
Copy link

I just had this same issue deploying on github pages, I don't think it's a bug though.
I believe in your case you are specifying the favicons like below:

  assets:
    favicon: "/assets/favicon.ico"

The starting slash makes the difference!

If you do put the starting slash then what you get is: http://a.com/assets/favicon.ico with the base part of the URL removed.
If you do not put the starting slash then what you get is exactly what you want, and the additional base part of the URL is preserved -> http://a.com/base/assets/favicon.ico.

Hope it helps!

@ahogen
Copy link

ahogen commented Sep 20, 2024

The starting slash makes the difference!

Indeed it does, thanks for this tip! I've removed the first slash and fixed my config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants