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

Empty section pages created when using nested taxonomies #12188

Closed
jmooring opened this issue Mar 1, 2024 · 3 comments
Closed

Empty section pages created when using nested taxonomies #12188

jmooring opened this issue Mar 1, 2024 · 3 comments

Comments

@jmooring
Copy link
Member

jmooring commented Mar 1, 2024

Not sure if this is a bug, but the result is different (undesirable) when comparing v0.123.7 to v0.122.0.

Scenario

  • Multilingual single-host site
  • English site has content, Japanese site has no content
  • Site has a language switcher to switch between langs on each page
  • Taxonomies are "nested' by content type (support for this is not documented, but I've seen it used on several sites):
[taxonomies]
'papers/category' = 'papers/category'
'blog/category' = 'blog/category'

Expected (v0.122.0)

public/ja/
├── blog/
│   └── category/
│       └── index.html
├── papers/
│   └── category/
│       └── index.html
└── index.html

Actual (v0.123.6)

public/ja/
├── blog/
│   ├── category/
│   │   └── index.html
│   └── index.html     <-- problem: has section page despite lack of content
├── papers/
│   ├── category/
│   │   └── index.html
│   └── index.html     <-- problem: has section page despite lack of content
└── index.html 

Why is this a problem?

When visiting the "blog" section page on the English site, the language switcher indicates that there is a Japanese translation, which is (obviously) just an empty page.

Test case

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

	files := `
-- hugo.toml --
disableKinds = ['rss','sitemap']
defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true
[languages.en]
weight = 1
[languages.ja]
weight = 2
[taxonomies]
's1/category' = 's1/category'
-- layouts/_default/single.html --
{{ .Title }}|
-- layouts/_default/list.html --
{{ .Title }}|
-- content/s1/p1.en.md --
---
title: p1
---
`

	b := hugolib.Test(t, files)

	b.AssertFileExists("public/en/s1/index.html", true)
	b.AssertFileExists("public/en/s1/p1/index.html", true)
	b.AssertFileExists("public/en/s1/category/index.html", true)

	b.AssertFileExists("public/ja/s1/index.html", false) // failing test
	b.AssertFileExists("public/ja/s1/category/index.html", true)
}

Reference: https://discourse.gohugo.io/t/hugo-attempting-to-build-pages-on-multilingual-site-for-languages-with-no-content/48561/4

@AlanBreck
Copy link

AlanBreck commented Mar 1, 2024

Another way in which this causes problems is that templates can fail due to missing data on pages that weren't intended to build, nor have content.

For instance, I discovered this due to a template rendering data from the frontmatter, but since it was attempting to build for all defined languages, it was throwing errors. This is resolvable by wrapping in a with or if block, but if for some reason I wanted it to fail in the absence of data for actual content pages, this would be undesirable.

@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep self-assigned this Mar 7, 2024
@bep bep modified the milestones: v0.125.0, v0.123.8 Mar 7, 2024
bep added a commit to bep/hugo that referenced this issue Mar 7, 2024
@bep bep closed this as completed in 7afac3f Mar 7, 2024
@AlanBreck
Copy link

Thank you!

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