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

Non-existent two-part path results with 404 page which doesn't load css and js files when using relativeURLs: true #12471

Closed
bugok opened this issue May 7, 2024 · 2 comments

Comments

@bugok
Copy link

bugok commented May 7, 2024

What version of Hugo are you using (hugo version)?

0.124.1

Does this issue reproduce with the latest release?

I'm not sure. It's hard to reproduce locally.

More information

When accessing a two-level, non existent path of a website, css and js files don't load.

Accessing my website at https://www.noamlerner.com works great.
Accessing https://www.noamlerner.com/nonexistent results with a 404 with a page which can load the css and js files.
However, accessing https://www.noamlerner.com/nonexistent/another results with a 404 response, but css and js files can't load.

Looking at the developer tools console I see that the static content is trying to be retrieved from: https://www.noamlerner.com/nonexistent/. For example:

https://www.noamlerner.com/nonexistent/css/main.bundle.min.5ea5a2723a6600ec162c3206366e9a4fbb0c82f79711e724dea2dfe92a2a864f.css
https://www.noamlerner.com/nonexistent/site.webmanifest

For context, I am using the relativeURLs: true option in my hugo config. You can see in this discussion why: jpanther/congo#857.

Furthermore, I tried reproducing this with other random hugo websites I found, and got 3/3:

I searched github for websites which use relativeURLs: https://github.com/search?q=%22relativeURLs%3A+true%22+path%3A%2F%5Econfig%5C.yaml%2F&type=code

Examples:

All of them showed with the same behavior - when loading the a two-part, non-existent path - the 404 page can't load static content.

@bugok bugok changed the title Non-existent two-part path results with 404 page which doesn't load css and js files Non-existent two-part path results with 404 page which doesn't load css and js files when using relativeURLs: true May 7, 2024
@jmooring
Copy link
Member

jmooring commented May 7, 2024

image

The path begins with ./, so it is relative to the current page. It is not relative to the directory from which the assets are served. There's no way that will work.

And there is almost never a good reason to enable relativeURLs:
https://gohugo.io/content-management/urls/#relative-urls

Do not enable this option unless you are creating a serverless site, navigable via the file system.

This is a support issue. Please create a new topic in the Hugo forum if you need additional assistance. Thanks.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants