# :slug in the context of taxonomies

**URL:** <https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851>\
**Category:** Uncategorized\
**Tags:** taxonomy\
**Created:** [March 19, 2021, 10:20pm UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851 "2021-03-19T22:20:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![binderclip](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@binderclip](https://discourse.gohugo.io/u/binderclip)\
**Post date:** [March 19, 2021, 10:20pm UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/1 "2021-03-19T22:20:23Z")

</div>

According to the documentation, the value for :slug, if not explicitly overridden, is determined by the name of the content file. However, after doing some experimentation and looking at the files generated in the public folder, that doesn’t seem to be strictly the case. This is what I put in my config.toml file:

```auto
[taxonomies]
year = "year"

[permalinks]
year = "/post/:slug/" 

```

And in my front matter:

```auto
year: 2021

```

When I look at the public folder, this is what I see:

post  
-2021  
–index.html  
–index.xml

So to me it looks as if, in the case of a slug for a taxonomy, :slug by default refers to the term of the taxonomy, and not to the name of the markdown file. I’d just like to know whether I’m misunderstanding how this works. Thanks.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 19, 2021, 10:49pm UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/2 "2021-03-19T22:49:21Z")

</div>

[https://gohugo.io/content-management/urls/#permalink-configuration-values](https://gohugo.io/content-management/urls/#permalink-configuration-values)

> `:slug`  
> the content’s slug (or title if no slug is provided in the front matter)

I do not understand what you’re trying to do here.

---

<div class="post-metadata">

**Author:** ![binderclip](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@binderclip](https://discourse.gohugo.io/u/binderclip)\
**Post date:** [March 19, 2021, 11:09pm UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/3 "2021-03-19T23:09:44Z")

</div>

So, if, for example, I create a permalink like this:

```auto
[permalinks]
post = "textfiles/:slug"

```

This means, as I understand it, `:slug` is being replaced with `firstpost` or `secondpost`, or whatever the names of the markdown files are in the section `post`. So when I generate the public folder I get paths like:

```auto
textfiles/firstpost
textfiles/secondpost

```

Indeed, if I do that I get a hierarchy like this in my public folder:

textfiles  
-firstpost  
–index  
-secondpost  
–index

This is what I would expect, based on that quote from the documentation.

However, if, instead of a `section`, I am binding(?) a permalink to a `taxonomy`, I get the result I showed in my original post, which is not in accord with that quote from the documentation. It looks like the paths being generated from

```auto
year = "post/:slug/"

```

are like this:

```auto
post/2020
post/2021

```

not like this:

```auto
post/firstpost
post/secondpost

```

Am I missing something, or does the documentation need to be updated?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 19, 2021, 11:30pm UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/4 "2021-03-19T23:30:48Z")

</div>

> [@binderclip](#):
>
> This means, as I understand it, `:slug` is being replaced with `firstpost` or `secondpost` , or whatever the names of the markdown files are in the section `post` .

No.

`:slug` is replaced with `slug` from the post’s front matter, and if that is not specified it falls back to the `title` specified in the post’s front matter.

With a taxonony or term page, the title defaults to the name of the taxonomy or term unless you have created \_index.md pages for those items (e.g., content/tags/\_index.md, content/tags/foo/\_index.md).

Finally, your permalink configuration is setting the permalink of taxonomy pages, not content pages.

What are you trying to accomplish?

---

<div class="post-metadata">

**Author:** ![binderclip](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@binderclip](https://discourse.gohugo.io/u/binderclip)\
**Post date:** [March 20, 2021, 12:01am UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/5 "2021-03-20T00:01:48Z")

</div>

Thanks for the correction with regard to the :slug being replaced by the title. That makes sense. And what you say here:

> With a taxonony or term page, the title defaults to the name of the taxonomy or term unless you have created \_index.md pages for those items

basically clears up my confusion, but then you say that my permalink configuration is setting the permalink of taxonomy pages, not content pages. I didn’t think that it was setting the permalink of content pages, _but_ it looks to me that I am setting the permalink of _term_ pages, not taxonomy pages. I still have a _taxonomy_ page under the URL `site.com/year/` (Correct me if I’m wrong).

To further clarify, the contents of the public folder looks like this (the term page, from the permalink configuration):

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/3/33fc95e70190631b315b47f8c45c29e21d6232ec.png)

Is this correct?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 20, 2021, 12:43am UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/6 "2021-03-20T00:43:04Z")

</div>

> [@binderclip](#):
>
> _but_ it looks to me that I am setting the permalink of _term_ pages, not taxonomy pages.

You are correct. I meant term pages. In my defense, the internal vocabulary changed a few months ago. Term pages used be called taxonomy pages, and taxonomy pages used to be called taxonomy term pages. This was cleaned up in [v0.73](https://gohugo.io/news/0.73.0-relnotes/). There may be still be some places in the documentation that do not reflect the revised terminology.

This configuration:

```auto
[permalinks]
year = "post/:slug/"

[taxonomies]
year = "year"

```

with this content:

```auto
content
├── post
│ ├── post-1.md (front matter: year = ["2021"])
│ ├── post-2.md (front matter: year = ["2021"])
│ └── post-3.md (front matter: year = ["2021"])
└── _index.md

```

Generates this HTML:

```auto
public/
├── post
│ ├── 2021
│ │ ├── index.html
│ │ └── index.xml
│ ├── post-1
│ │ └── index.html
│ ├── post-2
│ │ └── index.html
│ ├── post-3
│ │ └── index.html
│ ├── index.html
│ └── index.xml
├── year
│ ├── index.html
│ └── index.xml
├── index.html
├── index.xml
└── sitemap.xml

```

So I think you’re good.

---

<div class="post-metadata">

**Author:** ![binderclip](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@binderclip](https://discourse.gohugo.io/u/binderclip)\
**Post date:** [March 20, 2021, 12:44am UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/7 "2021-03-20T00:44:17Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 20, 2021, 12:46am UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/8 "2021-03-20T00:46:33Z")

</div>

Keep in mind, if you were to create this content:

```auto
hugo new post/2021.md

```

it would be overwritten when you build the site.

Running `hugo --path-warnings` will tell you something’s wrong:

```auto
WARN 2021/03/19 17:44:21 Duplicate target paths: ....

```

---

<div class="post-metadata">

**Author:** ![binderclip](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@binderclip](https://discourse.gohugo.io/u/binderclip)\
**Post date:** [March 20, 2021, 12:50am UTC](https://discourse.gohugo.io/t/slug-in-the-context-of-taxonomies/31851/9 "2021-03-20T00:50:53Z")

</div>

Thanks, I’m making a note of it.
