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

Relative Paths in Custom 404 Page Not Resolving Correctly for Non-Root URLs #194

Open
zivmax opened this issue Jan 22, 2025 · 0 comments · May be fixed by #195
Open

Relative Paths in Custom 404 Page Not Resolving Correctly for Non-Root URLs #194

zivmax opened this issue Jan 22, 2025 · 0 comments · May be fixed by #195
Assignees

Comments

@zivmax
Copy link

zivmax commented Jan 22, 2025

When using Jekyll, the 404 page (defined with permalink: /404.html) does not correctly resolve relative paths for non-root URLs. This issue occurs because Jekyll infers the relative paths based on the URL being accessed, which causes styles, scripts, and other assets to fail to load when accessing non-existent pages at deeper URL levels.

Problem Description

For example:

  • Accessing a non-existent URL like <server>:<port>/non-exist renders the 404 page correctly, and all assets load as expected.
  • However, accessing a non-existent URL like <server>:<port>/non/exist causes the relative paths to be resolved incorrectly. The browser attempts to load assets from /non/assets/... instead of ../assets/... or /assets/..., resulting in the following errors:
[2025-01-22 12:32:51] ERROR '/non/exist' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/bootstrap-table/dist/bootstrap-table.min.css' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/bootstrap/dist/js/bootstrap.bundle.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/jquery/dist/jquery.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/@fortawesome/fontawesome-free/css/all.min.css' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/bootstrap-table/dist/bootstrap-table.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/luxon/build/global/luxon.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/mathjax/es5/tex-chtml.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/vanilla-lazyload/dist/lazyload.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/intersection-observer/intersection-observer.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/iframe-resizer/js/iframeResizer.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/scratchblocks.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/twemoji/dist/twemoji.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/page.css' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/mermaid.min.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/jekyll-theme-cs50.js' not found.
[2025-01-22 12:32:51] ERROR '/non/assets/page.js' not found.
[2025-01-22 12:32:51] ERROR '/non/favicon.ico' not found.

Expected Behavior

The 404 page should resolve all relative paths (e.g., /assets/...) correctly, regardless of the URL being accessed. For example, accessing <server>:<port>/non/exist should load assets from /assets/... or ../assets/... instead of /non/assets/....

Steps to Reproduce

  1. Set up a Jekyll site with a 404 page defined using permalink: /404.html.
  2. Access a non-existent root-level URL (e.g., <server>:<port>/non-exist). The 404 page should render correctly.
  3. Access a non-existent deeper-level URL (e.g., <server>:<port>/non/exist). The 404 page will render, but assets will fail to load due to incorrect relative path resolution.
@dmalan dmalan self-assigned this Jan 22, 2025
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

Successfully merging a pull request may close this issue.

2 participants