Moving taxonomy list page?

Hi,
Loving hugo, thanks for all the work thats gone into it. Everything is working smoothly and incredibly user friendly, however I have one catch.

I have a hugo site, part of that site contains a blog under /blog. By default the taxonomies appear under /tags yet I want them under /blog/tags, so I’ve modified this like so:

[taxonomies]
  tag = "tags"

[permalinks]
  tags = "/blog/tag/:slug/"

This works nicely, I can now access my tags under /blog/tag/something. However the tag list remains at /tags - I have two related questions:

  • How can I also relocate this (the tags list) to /blog/tags?
  • Additionally /blog/tag just shows a white page, I see no errors suggesting its looking for a layout or similar - what’s going on here?

Thanks!

Create a template for blog/tags to render the relevant posts with range

If you want to disable the page under /tags/ try creating an empty template for it and place it under the relevant PATH under /layouts/

Thanks for the reply.

Create a template for blog/tags to render the relevant posts with range

I attempted to do this but think I must be misunderstanding something. My expectation was I could create layouts/blog/tags.html or perhaps /layouts/blog/tags/list.html but it appears both are entirely ignored? I still just have a white page at /blog/tags. So I try creating a content page at content/blog/tags.md - but now /blog/tags just uses the layouts/_default/single.html template like all my other posts. Better than a white page, but not the template I wanted.

In your template under /layouts/_default/list.html try the following:

{{ if eq (.Permalink | string) "blog/tags/" }}
<---- Render posts with tags ---->
{{ end }}

More about this technique over here: Pass Frontmatter to Taxonomy Without _index.md

No dice, still get a white page. Should have also mentioned I tried /blog/tags/_index.html Is there any way to workout whats causing the white pages? I’m running with hugo server, sometimes I get a 404, sometimes I get an error, sometimes the server console spits out a list of pages that would have matched the one I requested. But this time I get a white page, with no other info anywhere.

Sounds like there is ambiguity in your project.

You need to share the source code to troubleshoot this further because I need to see the full context.

Sure no problem, I’ve pushed a minimal example here: https://github.com/adamgibbins/hugo_debugging_example which seems to reproduce the same issue. / works, /blog works, /blog/tags/one/ works and /tags works. But /blog/tags shows a white page.

This is running Hugo v0.54.0 just to confirm.

I have sent you a PR with the fix: https://github.com/adamgibbins/hugo_debugging_example/pull/1

Basically the fix is the following:

  • In config.toml enter disableKinds = ["taxonomyTerm"] to disable the creation of the /tags/ taxonomyTerm list page

  • Created content/blog/tags/_index.md

  • Changed the template under layouts/_default/list.html to:

{{ $string := "blog/tags/" | absURL | string }}
{{ if eq (.Permalink | string) $string }}
<---- Render posts with tags ---->
{{ else }}
<--- Existing code ---.
{{ end }}

It’s self explanatory. But if you have any questions just ask and I’ll explain it.

Thanks for your continued help, greatly appreciated. This looks to do exactly what I want, with one slight catch - it seems I have to create a content .md per tag before I can loop through it with {{ range .Pages }}. Is this correct? Not a big deal if so, just checking as its inconsistent with the taxonomy page that gave me tag listing abilities without content pages attached.

That is not quite the way we loop through tags. Please have a look at the Doc: Taxonomy Templates | Hugo

With that said if your use case is different then you can do what you mentioned (even though it will get a bit tedious down the line).

Ooops sorry, stupidly referred back to an old example I had rather than the doc…

Copying the doc however produces nothing: https://github.com/adamgibbins/hugo_debugging_example/blob/master/layouts/_default/list.html#L12

The param is empty?

Should be .Params.tags or similar. You need to reference the front matter tag parameter.

But that contains the tags of the tags index page? Do I have to give all the tags to the index page? But then the index page itself also appears on every tag page.

In your test repo I only see tags here: https://raw.githubusercontent.com/adamgibbins/hugo_debugging_example/master/content/blog/test.md

And also you have created a /tags/ section.

Usually we assign tags in content files not lists like you have done at your _index.md

In any case I am pretty busy at the moment so it would be best if you opened another Support Topic with your question about ranging through tags. Maybe someone else can help.

In your test repo I only see tags here

Right, 3 of them, I want those to be listed on /blog/tags. Just as previously they were on /tags.

And also you have created a /tags/ section.

You did that in your pull request? :slight_smile: https://github.com/adamgibbins/hugo_debugging_example/commit/2636117203d50225e61799837aec69cb8ab7c0ec
Without that index page, I just get a white page as previously reported.

In any case I am pretty busy at the moment so it would be best if you opened another Support Topic with your question about ranging through tags. Maybe someone else can help.

OK, thanks for your help.

Aha. As I said i’m busy today (or growing senile prematurely).