Unique taxonomies per section/type

If you want to have the same names for taxonomies but distinct taxonomy, how to do?

like:

/blog/category
/blog/tag
/project/tag
/publications/category

Thanks

content structure

content/
β”œβ”€β”€ books/
β”‚   β”œβ”€β”€ book-1.md
β”‚   └── book-2.md
β”œβ”€β”€ films/
β”‚   β”œβ”€β”€ film-1.md
β”‚   └── film-2.md
└── _index.md

site config

[taxonomies]
'books/genre' = 'books/genres'
'films/genre' = 'films/genres'

front matter

+++
title = 'Book 1'
date = 2023-02-08T09:52:15-08:00
draft = false
'books/genres' = ['romance']
+++
2 Likes

Hi Joe,

What do you think about that:

content

content/
β”œβ”€β”€ books/
β”‚   β”œβ”€β”€ book-1.md
β”‚   └── book-2.md
β”œβ”€β”€ films/
β”‚   β”œβ”€β”€ film-1.md
β”‚   └── film-2.md
β”œβ”€β”€ genres/
β”‚   β”œβ”€β”€ romantic.md
β”‚   β”œβ”€β”€ horror.md
β”‚   └── _index.md
β”œβ”€β”€ films_genres/
β”‚   β”œβ”€β”€ romantic.md
β”‚   β”œβ”€β”€ horror.md
β”‚   └── _index.md
└── _index.md

config

[taxonomies]
'genre' = 'genres'
'films_genre' = 'films_genres'

[permalinks]
'genres' = 'books/genres'
'films_genres' = 'films/genres'

front matter for romantic genre

+++
title = 'Romantique' 
+++

I need to have _index.md in taxonomies for translate the title.

This is a good way?

Thanks a lot

Is this is a multilingual site? If yes, your content structure above is incorrect.

not really.
I’m using Netlify CMS and I save content in english folder like:

content/
β”œβ”€β”€ books/
β”œβ”€β”€ films/

But my website could be in french

So, is the answer β€œyes” or β€œno” ?

@jmooring,

no :slight_smile:

No. That won’t work. The permalinks configuration settting does not apply to section pages, and each of your terms must be a section page. Using your suggestion, your content structure would have to be:

content/
β”œβ”€β”€ books/
β”‚   β”œβ”€β”€ book-1.md
β”‚   └── book-2.md
β”œβ”€β”€ films/
β”‚   β”œβ”€β”€ film-1.md
β”‚   └── film-2.md
β”œβ”€β”€ films_genres/
β”‚   β”œβ”€β”€ mystery/
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ romance/
β”‚   β”‚   └── _index.md
β”‚   └── _index.md
β”œβ”€β”€ genres/
β”‚   β”œβ”€β”€ mystery/
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ romance/
β”‚   β”‚   └── _index.md
β”‚   └── _index.md
└── _index.md

And getting the URLs to work the way you want cannot be done with permalinks. You could change the front matter url value for each of the term pages, but that’s a waste of time.

Use my initial suggestion.

Hi Joe,

I did this repo GitHub - sebousan/hugo-test-taxonomies
with, I think, your initial suggestion, true?

It’s better to have taxonomies inside their section insted of same level?
like this: hugolify-example-site/content at main Β· Hugolify/hugolify-example-site Β· GitHub
(this fake content is used for Hugolify Β· GitHub)
demo: https://demo.hugolify.com

thanks for your time.

Your content structure should look like this:

content/
β”œβ”€β”€ books/
β”‚   β”œβ”€β”€ genres/
β”‚   β”‚   β”œβ”€β”€ mystery/
β”‚   β”‚   β”‚   └── _index.md
β”‚   β”‚   β”œβ”€β”€ romance/
β”‚   β”‚   β”‚   └── _index.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ book-1.md
β”‚   └── book-2.md
β”œβ”€β”€ films/
β”‚   β”œβ”€β”€ genres/
β”‚   β”‚   β”œβ”€β”€ mystery/
β”‚   β”‚   β”‚   └── _index.md
β”‚   β”‚   β”œβ”€β”€ romance/
β”‚   β”‚   β”‚   └── _index.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ film-1.md
β”‚   └── film-2.md
└── _index.md

That won’t work with nested taxonomies.

Hi Joe,

I’m afraid I don’t understand.
I do not understand the gain in relation to my structure

How to configure [permalinks] to have:

  • /books β†’ /livres
  • /books/genres β†’ /livres/types (genres is the same word in french, I change it for this example)
  • /books/genres/romatic β†’ /livres/types/romantique

I doesn’t want to use url in frontmatter to do that

We are not communicating very well.

Please try this.

git clone --single-branch -b hugo-forum-topic-42828 https://github.com/jmooring/hugo-testing hugo-forum-topic-42828
cd hugo-forum-topic-42828
hugo server

I’m sorry, I’ll try to be more clear

thanks, its great.
So I need to keep (for netlify cms) your structure and name of folders but I would like translate it to french (only one language): title and permalinks (not the folders names).
Permalinks becomes:

  • http://localhost:1313/books/book-1/ become http://localhost:1313/livres/livre-1/
  • http://localhost:1313/books/genres/mystery/ become http://localhost:1313/livres/genres/mytere

this is my problem

So this URL is OK?

And this one is not?

yes with permalinks like:

[permalinks]
books = 'livres/:slug'
'books/genres' = 'livres/genres/:slug'

There is an open issue (proposal) about this:
https://github.com/gohugoio/hugo/issues/8523


To get this:

http://localhost:1313/livres/

You need to do this:

content/books/_index.md

+++
title = 'Livres'
date = 2023-02-10T13:17:44-08:00
draft = false
url = 'livres'
+++

To get this:

http://localhost:1313/livres/genres/

You need to do this:

content/books/_index.md

+++
title = 'Genres (books)'
date = 2023-02-09T05:35:49-08:00
draft = false
url = 'livres/genres'
+++

To get this:

http://localhost:1313/livres/genres/romance/

You need to do this:

content/books/genres/romance/_index.md

+++
title = 'Romance (books)'
date = 2023-02-09T05:33:42-08:00
draft = false
url = 'livres/genres/romance'
+++

If I were you, since this is a monolingual site, I would rename the directories and not use permalinks.