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

Section page resource not published if resource filename partially matches content file name #12198

Closed
mwegnr opened this issue Mar 4, 2024 · 3 comments

Comments

@mwegnr
Copy link

mwegnr commented Mar 4, 2024

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

$ hugo version
hugo v0.123.7-312735366b20d64bd61bff8627f593749f86c964+extended linux/amd64 BuildDate=2024-03-01T16:16:06Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes, reproducible from 0.123.0 to latest (0.123.7)

Problem Description

When a page-file has the same basename as the resources in the folder, the resources do not get included in the page build with hugo. This was different in hugo 0.122.0.

This folder structure

content/news
content/news/renamed_test.pdf
content/news/test.md
content/news/test.png
content/news/test.pdf
content/_index.md

results in this page structure

public/index.html
public/news
public/news/index.html
public/news/renamed_test.pdf
public/sitemap.xml

When using 0.122.0, the page structure is

public/index.html
public/news
public/news/index.html
public/news/renamed_test.pdf
public/news/test.png
public/news/test.pdf
public/sitemap.xml

Minimal Example Project

Project with the example structure above can be found here: https://github.com/mwegnr/hugo-resource-copy

@jmooring
Copy link
Member

jmooring commented Mar 4, 2024

@mwegnr Thanks for this. Note that resources even beginning with the same name are excluded (e.g., news/test-foo.ext).

@jmooring
Copy link
Member

jmooring commented Mar 4, 2024

Content

content/
└── s1/
    ├── foo.txt
    ├── p1-foo.txt
    ├── p1.md
    └── p1.txt

Expected (v0.122.0)

public/
└── s1/
    ├── p1/
    │   └── index.html
    ├── foo.txt
    ├── index.html
    ├── p1-foo.txt
    └── p1.txt

Actual (v0.123.7)

public/
└── s1/
    ├── p1/
    │   └── index.html
    ├── foo.txt
    └── index.html

Failing test case

test case
func TestFoo(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['home','rss','sitemap','taxonomy','term']
-- content/s1/p1.md --
---
title: p1
---
-- content/s1/foo.txt --
foo.txt
-- content/s1/p1.txt --
p1.txt
-- content/s1/p1-foo.txt --
p1-foo.txt
-- layouts/_default/list.html --
{{.Title }}|
-- layouts/_default/single.html --
{{.Title }}|
	`

	b := hugolib.NewIntegrationTestBuilder(
		hugolib.IntegrationTestConfig{
			T:           t,
			TxtarString: files,
		},
	)
	b.Build()

	b.AssertFileExists("public/s1/index.html", true)
	b.AssertFileExists("public/s1/foo.txt", true)
	b.AssertFileExists("public/s1/p1.txt", true)     // failing test
	b.AssertFileExists("public/s1/p1-foo.txt", true) // failing test
	b.AssertFileExists("public/s1/p1/index.html", true)
}

@jmooring jmooring changed the title Resources (pdf, png) not included in bundle when page-file with same name exists in folder Page resource not published if resource filename partially matches content file name Mar 4, 2024
@bep bep self-assigned this Mar 7, 2024
@bep bep added this to the v0.123.8 milestone Mar 7, 2024
@bep bep changed the title Page resource not published if resource filename partially matches content file name Branch page resource not published if resource filename partially matches content file name Mar 7, 2024
@bep bep changed the title Branch page resource not published if resource filename partially matches content file name Page resource not published if resource filename partially matches content file name Mar 7, 2024
@bep bep changed the title Page resource not published if resource filename partially matches content file name Section page resource not published if resource filename partially matches content file name Mar 7, 2024
bep added a commit to bep/hugo that referenced this issue Mar 7, 2024
@bep bep closed this as completed in 4271b6b Mar 7, 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 Mar 29, 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

3 participants