I need a taxonomy that follows this URL structure:
example.com/tema/labas
The category would be labas
and the term for the category would be tema
.
How do I go about doing this?
I need a taxonomy that follows this URL structure:
example.com/tema/labas
The category would be labas
and the term for the category would be tema
.
How do I go about doing this?
Not really a localization issue, me thinks. You can add arbitrary taxonomies (meaning anything you can think of), and you can read all about it at using taxonomies.
I saw that, it wasn’t very informative.
Are all taxonomies just an array? A category can be a taxonomy, but does it still work like tags would? Or a variable?
From the taxonomy overview (emphasis mine):
The default taxonomies for Hugo are tags and categories. These taxonomies are common to many website systems (e.g. WordPress, Drupal, Jekyll). Unlike all of those systems, Hugo makes it trivial to customize the taxonomies you will be using for your site however you wish. Another good use for taxonomies is to group a set of posts into a series. Other common uses would include categories, tags, groups, series and many more.
In Hugo a taxonomy is just a piece of metadata, so categories and tags are the same, function-wise. If you are coming from WordPress than the difference between categories and tags is that the former are hierarchal and the latter are freeform. As far as I know, all taxonomies act like tags in WordPress.
I re-read that, and realized you want the taxonomy to come after the term in the URL, which is different than how folks usually how it. If your taxonomy is “labas” and the term is “tema”, you usually get:
example.com/labas/tema
So now I am not sure what you are asking. I thought you just wanted a custom taxonomy, but you actually want to know how to create that URL scheme, ne? As in example.com/<TERM>/<TAXONOMY>
?
As an addendum, I want to point out the new docs for taxonomies are probably more informative, and there is a mention about taxonomy URLs:
Note also that taxonomy permalinks are not configurable.
So at this point you may not be able to create that URL pattern.
Also referenced in that document about default taxonomies:
Users of versions older than v0.20 may notice that Hugo built /tags and /categories as long as these fields were called in at least a single content file. A previous hack involved setting these values to empty strings. This is not a proper workaround.
As of v0.20, Hugo does not automatically generate default taxonomies for your site. If your site configuration contains no key-values in the taxonomies field, Hugo will not build anything.
In the case that you haven’t added your taxonomy to your site, you’d put the following in your config.toml
(presuming TOML):
[taxonomies]
laba = "labas"
Note: I don’t actually know what language that is, but the first part is singular, and the second part is plural.
Once you’ve defined your taxonomy add a piece of content, and put the following in your frontmatter:
+++
title = "Hugo: A fast and flexible static site generator"
labas = [ "tema", "other labas" ]
+++
And when you build the site it will create a taxonomy page at /labas/tema
.
Also note that taxonomy terms and taxonomy list pages can also have content pages, so that can be a way to add a custom Title
. This can be a lot of work for lots of tags, and I think there is an open issue talking about this in more detail on GitHub.
This is not what I want. I want this:
example.com/<TAXONOMY>/<TERM>
In English, this is what it’d look like:
example.com/topic/hello
But since I’m not making the site in English, it becomes this:
pavyzdys.lt/tema/labas
As an addendum, I want to point out the new docs for taxonomies are probably more informative, and there is a mention about taxonomy URLs…
Yeah, the docs linked there are better.
I’ll reply if I have more questions
That’s cool. I was confused by your first post, because of the way you describe “category” and “term”. Taxonomies have terms. So you’d describe it as “tema” being your taxonomy, and “labas” as your term.
In your config you’d put something like:
[taxonomies]
tema = "temas"
And in frontmatter:
+++
title = "Hugo: A fast and flexible static site generator"
temas = [ "labas" ]
+++
That will create /tema/labas
for ya, using the taxonomy template lookup order.