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

livereload.js does not load when using an alternative base path #2742

Open
witchof0x20 opened this issue Dec 19, 2024 · 5 comments
Open

livereload.js does not load when using an alternative base path #2742

witchof0x20 opened this issue Dec 19, 2024 · 5 comments

Comments

@witchof0x20
Copy link

Bug Report

I am locally testing a zola project using
zola serve --base-url http://localhost/project

This is to mimic how github pages lays out a subdirectory, so I can make sure my links are robust to being on a subdirectory.

However, when serving, zola injects <script src="/livereload.js?port=1024&amp;mindelay=10"></script></body>

because this isn't under the base path, this script fails to load.

I think the fix is just adding the base url to the format string here: https://github.com/getzola/zola/blob/master/components/site/src/lib.rs#L576

Environment

Zola version: 0.19.2

Expected Behavior

livereload.js loads properly

Current Behavior

GET http://localhost:1111/livereload.js 404s

Step to reproduce

zola serve --base-url http://localhost/project

@harrymkt
Copy link
Contributor

<script src="{{ get_url(path = "livereload.js") }}?port=1024&amp;mindelay=10"></script></body>

@witchof0x20
Copy link
Author

I could probably hack that in, but it seems like a pretty small codechange to fix it in Zola itself.

@Keats
Copy link
Collaborator

Keats commented Dec 20, 2024

I think that's fine to do a PR to add that to the next branch

@harrymkt
Copy link
Contributor

@witchof0x20 I could probably hack that in, but it seems like a pretty small codechange to fix it in Zola itself.

No, because some may want to reference the functions from the main website, for example, say:

web is the main website, and subweb is the subfolder in it, like GitHub pages.

And then user places the functions.js in the main website (web), and reference in the subweb using /functions.js, thereby the JS is fetched from the main repository, no need to copy over.

Of course if this option would be implemented, a config option to turn this off will need to be advised alongside that one.

@karamfd
Copy link

karamfd commented Jan 3, 2025

The zola serve command stopped working for me as well when making changes to static pages locally.

The pages do not automatically update and I have to restart the server each time I make a new change.

I'm using zola 0.19.2 on Mac OS Sequoia 15.2

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