Talk page with Taxonomy

What I want to do with Hugo, is to have pages and tags as you would normally
have. But in addition to that, I would like the option, of being able to have a
“Talk” page linked to any type of page. So if I have a normal page:

content/sunday/index.md

I would also like the option of making a Talk page:

content/sunday/talk/index.md

that can be accessed from the normal page. This is similar to Talk page on
Wikipedia, or Discussion page with Rosetta Code:

With normal pages, I find that I can do this:

content/sunday/_index.md

Then I am able to add Talk page no problem. However I might also want to add
Talk page to a Taxonomy, like this:

content/tags/talk/index.md

So I tried to implement that by creating:

content/tags/_index.md

but the Talk page is not recognized. Is this something that is possible?

I’d suggest that you create a minimal git repo showing the issue. Then anyone can clone that repo and tinker with it to help get you what you want.

Here’s one of my minimal repo’s for hugo: https://gitlab.com/hugo-mwe/hugo-issue-5615

Here is the repo:

https://github.com/muv1/hugo

as can be seen, the “tags/talk” page is created (youll need to browse manually,
I am not allowed many links per post):

public/tags/talk/index.html

but the “tags” page does not see it:

public/tags/index.html

Here is the loop code:

{{ range .Pages }}
   {{ . }}
{{ end }}
layouts/_default/list.html

The loop picked up tagged pages, but not pages that are physically in the same
folder or subfolder. If some loop is available to capture those files, it would
solve the problem.

“tags” is a special section… it’s for listing the tags that you actually use in your content.

In your repo, you were using a “day” tag, but not the “talk” tag. So that that page won’t list on the “tags” page.

  • See here where I add some more info to your content and slightly tweak the layout so that the debug becomes a bit more easier (at least for me)
  • This commit is the actual fix… there I use the “talk” tag, and then that tag page shows up on the tags/ list page.
    image

As an aside, also have a look at this “bare min” theme that I created as I was learning the ins and outs of Hugo. It puts out a lot of debug info on the published pages (like this).

What youve done is create a new tag, talk.

The result of this, is that when you navigate to tags/talk, you will be
viewing of list of all pages with the talk tag. I dont want that. When I
navigate to tags/talk, I want to be viewing a single page. A page that is
notes or information about the tags page. The reason is this: some pages are
lists of items, for example:

  • tags
  • tags/day

and in some cases these lists can be quite large. To add to that, notes or
content that I might want to add to these pages could be quite large as well.
What I dont want, is a large list, and a large amount of content on the same
page. Wikipedia and Rosetta Code handle this quite well. If you visit a tag
page:

https://rosettacode.org/wiki/Category:Go

you get a large list of items. But you also get a separate “Discussion” link
where you can dump content without crowding the listing page.

Then may be you just need a .GetPage "talk" like this.

image

Check out the demo on https://hungry-brown-520e14.netlify.app/


Now to avoid situations like this ( https://hungry-brown-520e14.netlify.app/sunday/ ), where “talk” is a special page, you may need to give those pages a special layouts or tags frontmatter to filter from out of the normal .Pages loop.

I think I finally sorted it. The issue was that running .Pages on a taxonomy
page would miss any physical files in the folder.

This was solved by your suggestion of .GetPage. However that introduced
another problem. I also want to use .GetPage with section pages, so that I
can separate the Talk page from the .Pages loop. As you mentioned, this
creates duplicate Talk page entries.

I didnt really like your suggestions for dealing with that, but I was able to
find this:

https://gohugo.io/content-management/build-options

It seems for the Talk pages under section pages, that if I add this:

_build:
   list: never

It removes the Talk page from the .Pages loop, but still allows it to be
pulled with .GetPage. All this seems to make a complete solution, so thank
you!

Hm actually I noticed another issue. The act of creating these:

content/tags/_index.md
content/tags/talk/index.md

Causes /tags to populate in the .Pages loop on the home page. I dont want
that if possible, as I already have link in the header to the Tags page. I
tried getting it out of the loop by adding:

_build:
   list: never

but Hugo just ignored the setting. Any ideas?

To work around this issue, I just stopped putting anything in
content/categories or content/tags. Instead, I put them here:

content/talk/categories
content/talk/tags

Then you can use something like this:

{{ with (.GetPage (path.Join "talk" .Path)) }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{ end }}

Try using .RegularPages slice.

I only want to kill taxonomies from the home page, not sections.

.RegularPages kills both. So if I had something like this:

content/sunday/_index.md
content/sunday/talk/index.md

It would be gone too from the home page.