Skip to content

Conversation

satotake
Copy link
Contributor

@satotake satotake commented Aug 7, 2022

Currently, Hugo does not inject livereload script if html does not contain <head> or <body>.
This sometimes happens if you create new sites without theme and it is hard to catch the cause soon.

This PR:

  • Inject livereload script even if html does not include <head>, <body>, or <html>
    • Modern browsers execute scripts even if they are outside <html>
    • Some js frameworks (confirmed with vite) inject HRM script without <html> tag
  • Append warning script to html if <head> or <body> is not in html
  • Fix bug that livereload cannot be appended to the tags with attrs

Close #10105

Currently, Hugo does not inject `livereload` script if html does not contain `<head>` or `<body>`. This sometimes happens if you create new sites without `theme` and it is hard to catch the cause soon.

This PR:

* Inject livereload script even if html does not include `<head>`, `<body>`, or `<html>`
    - Modern browsers execute scripts even if they are outside `<html>`
    - Some js frameworks (confirmed with vite) inject HRM script without `<html>` tag
* Append warning script to html if `<head>` or `<body>` is not in html
* Fix bug that livereload cannot be appended to the tags with attrs

Close gohugoio#10105
@satotake satotake force-pushed the livereload-fallbak-and-warning branch from abf8c32 to f634c84 Compare August 7, 2022 14:42
@bep bep merged commit b017f7c into gohugoio:master Aug 7, 2022
@hueralin
Copy link

warn: "head" or "body" tag is required in html to append livereload script. As a fallback, Hugo injects it somewhere but it might not work properly.

Is it possible that I need to add head, body tags to every page, even the page files in the partials directory?

Copy link

This pull request 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 Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print a warning when LiveReload fails to inject its code
3 participants