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

taxonomy.html and terms.html reversed #10048

Closed
gumaerc opened this issue Jun 24, 2022 · 4 comments
Closed

taxonomy.html and terms.html reversed #10048

gumaerc opened this issue Jun 24, 2022 · 4 comments

Comments

@gumaerc
Copy link

gumaerc commented Jun 24, 2022

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

$ hugo version
hugo v0.101.0+extended linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes, I'm using the latest release

This discourse thread describes the exact issue I'm experiencing here with the latest version of Hugo today. I have layouts defined in my Hugo theme at layouts/learning_resource_types/taxonomy.html as well as layouts/learning_resource_types/terms.html and the taxonomy kind seems to be selecting terms.html where term kinds are selecting the taxonomy.html template. I added debug lines to my template to prove this, with <div>{{ printf "%#v" .Kind }}</div> in my baseof.html to print the kind of the current page, and a literal <div>taxonomy.html</div> in my taxonomy.html template as well as a <div>terms.html</div> in my terms.html template. It results in the following:

image
image

As you can see, when the kind of the page is taxonomy, terms.html is being selected whereas if the kind is term, taxonomy.html is being selected.

Side note: we are using the permalinks directive to redirect our learning_resource_types taxonomy pages to /resources which is why you see the URLs for this at /resources.

@gumaerc gumaerc changed the title taxonomy.html and term.html reversed taxonomy.html and terms.html reversed Jun 24, 2022
@bep
Copy link
Member

bep commented Jun 24, 2022

We have a million tests for this, so I'm pretty sure this works as designed. I don't know your setup, though, so I cannot tell what's happening.

I suggest you raise a new thread on the forum.

@bep bep closed this as completed Jun 24, 2022
@gumaerc
Copy link
Author

gumaerc commented Jun 24, 2022

@bep Okay, will do and thanks for taking a look. For what it's worth, I was able to reproduce this with a fresh Hugo project as well.

config.toml:

baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
[taxonomies]
test_taxonomy = "test_taxonomy"
[outputs]
home = [ 'HTML' ]
page = [ 'HTML' ]
section = [ 'HTML' ]
taxonomy = [ 'HTML' ]
term = [ 'HTML' ]

content/test_pages/test_1.md:

---
test_taxonomy:
 - taxonomy1
---

layouts/test_taxonomy/taxonomy.html:

<html>
<head></head>
<body>
<div>{{ printf "%#v" .Kind }}</div>
<div>taxonomy.html</div>
</body>
</html>

layouts/test_taxonomy/terms.html:

<html>
<head></head>
<body>
<div>{{ printf "%#v" .Kind }}</div>
<div>terms.html</div>
</body>
</html>

In the output:
public/test_taxonomy/index.html:

<html>
<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script></head>
<body>
<div>&#34;taxonomy&#34;</div>
<div>terms.html</div>
</body>
</html>

public/test_taxonomy/taxonomy1/index.html:

<html>
<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script></head>
<body>
<div>&#34;term&#34;</div>
<div>taxonomy.html</div>
</body>
</html>

Am I missing something here about the terminology? I was under the impression that "test_taxonomy" here is the Taxonomy, and "taxonomy1" is the term, and the layout selection seems to be obviously reversed. I uploaded my test project here if you'd like to take a look: https://drive.google.com/file/d/19xizGJJ69an7iA7fkLsEZ10ufm4KKaCJ/view?usp=sharing

Edit: for clarity I should have named "taxonomy1" "term1" or something, but it shouldn't matter either way.

@gumaerc
Copy link
Author

gumaerc commented Jun 24, 2022

@bep I cleaned up my example and put it into a Github repo for easy access here: https://github.com/gumaerc/hugo-taxonomy-template-bug

@github-actions
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 Jul 16, 2022
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

2 participants