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

Stale content issue on server rebuilds with Markdown content included with short refs in site.GetPage #13004

Closed
bep opened this issue Nov 3, 2024 · 1 comment
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Nov 3, 2024

I had a head scratching moment investigating a bug in the wild.

Here's a failing test:

func TestRenderShortcodesIncludeShortRefEdit(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableLiveReload = true
disableKinds = ["home", "taxonomy", "term", "section", "rss", "sitemap", "robotsTXT", "404"]
-- content/first/p1.md --
---
title: "p1"
---
## p1-h1
{{% include "p2" %}}
-- content/second/p2.md --
---
title: "p2"
---
### p2-h1
-- layouts/shortcodes/include.html --
{{ $p := site.GetPage (.Get 0) -}}
{{ $p.RenderShortcodes -}}
-- layouts/_default/single.html --
{{ .Content }}
`
	b := TestRunning(t, files)
	b.AssertFileContentEquals("public/first/p1/index.html", "<h2 id=\"p1-h1\">p1-h1</h2>\n<p></p>\n<h3 id=\"p2-h1\">p2-h1</h3>\n<p></p>\n")

	b.EditFileReplaceAll("content/second/p2.md", "p2-h1", "p2-h1-edited").Build()
	b.AssertFileContentEquals("public/first/p1/index.html", "<h2 id=\"p1-h1\">p1-h1</h2>\n<p></p>\n<h3 id=\"p2-h1-edited\">p2-h1-edited</h3>\n<p></p>\n")
}

The above test passes if you use the full path to the content file to include:

{{% include "second/p2" %}}
@bep bep added the Bug label Nov 3, 2024
@bep bep self-assigned this Nov 3, 2024
@bep bep added this to the v0.137.0 milestone Nov 3, 2024
bep added a commit to bep/hugo that referenced this issue Nov 3, 2024
bep added a commit to bep/hugo that referenced this issue Nov 3, 2024
@bep bep closed this as completed in 30d9aea Nov 3, 2024
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 Nov 25, 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

1 participant