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

watch not working on custom output template #13014

Closed
razonyang opened this issue Nov 5, 2024 · 5 comments · Fixed by #13304
Closed

watch not working on custom output template #13014

razonyang opened this issue Nov 5, 2024 · 5 comments · Fixed by #13304
Assignees
Milestone

Comments

@razonyang
Copy link
Contributor

razonyang commented Nov 5, 2024

Reproducer

// hugo.yaml
outputFormats:
  SearchIndex:
    baseName: 'Search'
    isPlainText: true
    mediaType: 'application/json'
    noAlternative: true

outputs:
  home:
    - HTML
    - SearchIndex
// layouts/_default/index.searchindex.json
{{ partial "index.json" . }}
// layouts/partials/index.json
{{ $data := dict
  "version" 1
}}
{{ jsonify $data }}

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

$ hugo version
hugo v0.137.0-59c115813595cba1b1c0e70b867e734992648d1b+extended linux/amd64 BuildDate=2024-11-04T16:04:06Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes. It was also present in earlier versions, such as 0.128.0.

@bep
Copy link
Member

bep commented Nov 5, 2024

I'm pretty sure the issue title isn't true in general, so it must something ... special.

  • What do you mean by watch? hugo server --watch?
  • Do you have a complete and failing example living somewhere?

@bep bep added the S0 label Nov 5, 2024
@razonyang
Copy link
Contributor Author

  • What do you mean by watch? hugo server --watch?

Yes, hugo server --watch.

  • Do you have a complete and failing example living somewhere?

I just created a testing branch with the code snippets mentioned above.

git clone -b custom-output-watch [email protected]:razonyang/hugo-testing.git hugo-13014

cd hugo-13014

hugo server --watch -p 1111

And then I modified the layouts/partials/index.json, http://localhost:1111/search.json won't re-render until restarting Hugo server.

I can reproduce it on both Linux (as shown in the video I posted) and Windows.

@ibuli
Copy link

ibuli commented Nov 12, 2024

+1 This issue is also happening to me - the changes are not reflecting if change a particular file until we restart the server.
Currently using hugo v0.114.0+extended darwin/arm64 BuildDate=unknown

@bep bep added this to the v0.142.0 milestone Jan 6, 2025
@bep bep modified the milestones: v0.142.0, v0.143.0, Unscheduled Jan 22, 2025
@gohugoio gohugoio deleted a comment from Whickey344 Jan 23, 2025
@bep bep self-assigned this Jan 23, 2025
@bep bep modified the milestones: Unscheduled, v0.143.0 Jan 23, 2025
@bep
Copy link
Member

bep commented Jan 23, 2025

@razonyang I can reproduce this using your setup. I see what happens and I will try to get a fix into the next release, but the*If you run with hugo server --disableFastRender, your example site works, and could possibly be a workaround.

bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as ´noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
bep added a commit to bep/hugo that referenced this issue Jan 24, 2025
The failing test case here is

* A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable`
* In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed.

There are variants of the above, but the gist of it is:

* The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it.

Running with `hugo server --disableFastRender` would be a workaround for the above.

This commit fixes this by:

* Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet).
* Making sure that we compare against the real relative URL for non-permalinkable output formats.

Fixes gohugoio#13014
@bep bep closed this as completed in cd7dc7a Jan 24, 2025
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 Feb 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants