Hierarchical content


#1

Hi,

My site has two content sections - content/blog/java and content/blog/go. I have different set of tags for java and go. I would like three different pages:

  1. mysite/blog - list all the posts under both sections - java and go
  2. mysite/blog/java - list all posts under java - and listing tags related to java section
  3. mysite/blog/go - list all posts under go and listing tags related to go section

How do I achieve this?

Regards,
Radha.


#2

There are lots of ways to organize your content and get that result. Please consult https://gohugo.io/content-management/ and try a few things. :slight_smile:


#3

I sure did, before I posted the question here.

I’ve tried having _index.md in the leaf folders (go, java), and tried having _index.md in blog. But the posts don’t get listed like I wanted.

Any specific approach you could suggest?


#4

More specifically, how do I achieve the tags per section part? Tags seem to be global, across sections. Is there a way I can specify a hierarchy?


#5

I think you can do what you want using taxonomies all posts would live under the same blog section but the tags is what will decide where they render.

So make a blog taxonomy and then tag your posts with java or go.


#6

Not that I know of. The taxonomies are flat.

I wouldn’t make a suggestion without seeing the actual content and current IA. You asked about creating three specific URLs, but I would never use that scheme, so I have no suggestions. :slight_smile:


#7

I believe Hugo added a feature for this in recent update to archetypes, where you can specify different archetypes (which includes setting tags, etc) for different hierarchies.

I haven’t tried it, so I could be wrong. But you should try it out, and report back on how that worked :slight_smile:


#8

Could you point that out? I’m curious as to how that works. :slight_smile:


#9

As I said, I haven’t need to use this feature, as I use the structural hierarchy feature in Org mode. I simply tag an Org mode subtree with “foo” tag, and all posts under that subtree will have that tag.


Set frontmatter variables from templates? How?