# Does Hugo support categories in the permalink?

**URL:** <https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984>\
**Category:** support\
**Created:** [March 28, 2015, 11:50pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984 "2015-03-28T23:50:43Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![kidoman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kidoman/32/348_2.png) [@kidoman](https://discourse.gohugo.io/u/kidoman)\
**Post date:** [March 28, 2015, 11:50pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/1 "2015-03-28T23:50:43Z")

</div>

I am trying to port over a Octopress blog over to Hugo, and was wondering if a post permalink like:

```auto
/:categories/:title.html

```

would work!

[http://gohugo.io/extras/permalinks/](http://gohugo.io/extras/permalinks/) is not very encouraging!

---

<div class="post-metadata">

**Author:** ![spf13](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/spf13/32/37_2.png) [@spf13](https://discourse.gohugo.io/u/spf13)\
**Post date:** [March 29, 2015, 12:12am UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/2 "2015-03-29T00:12:19Z")

</div>

It depends what you mean by “categories”. In Hugo terminology that’s probably section… but the default behavior of Hugo is already /:section/:title/ so that’s pretty much what you want. If you turn on ugly urls it will do it exactly as you’ve specified here.

---

<div class="post-metadata">

**Author:** ![kidoman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kidoman/32/348_2.png) [@kidoman](https://discourse.gohugo.io/u/kidoman)\
**Post date:** [March 29, 2015, 12:16am UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/3 "2015-03-29T00:16:03Z")

</div>

So in my Octopress blog, I had front matter like so:

```auto
---
layout: post
title: "Chrome DevTools Profiling Demystified"
date: 2013-05-12 09:30
comments: true
category: engineering
---

```

And that would end up with a url like: [http://kidoman.io/engineering/chrome-profiling-demystified.html](http://kidoman.io/engineering/chrome-profiling-demystified.html)

So the :categories would get picked up from the front matter and used in the URL.

See: [http://jekyllrb.com/docs/permalinks/#template-variables](http://jekyllrb.com/docs/permalinks/#template-variables)

---

<div class="post-metadata">

**Author:** ![spf13](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/spf13/32/37_2.png) [@spf13](https://discourse.gohugo.io/u/spf13)\
**Post date:** [March 29, 2015, 12:32am UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/4 "2015-03-29T00:32:29Z")

</div>

Hugo just does things differently. You can specify the section in the front matter and it would work the exact same way. No permalinks needed. You also don’t need to specify the layout in hugo (unless it’s different for that post). It will guess it from the section.

---

<div class="post-metadata">

**Author:** ![doesntgolf](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@doesntgolf](https://discourse.gohugo.io/u/doesntgolf)\
**Post date:** [May 24, 2016, 8:35pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/5 "2016-05-24T20:35:11Z")

</div>

Sorry to bump an old thread, but I’m currently trying to set section in the front matter, and it doesn’t seem to be acting as I was expecting. I’m currently on the 0.15 release.

There seems to be a bit of contradictory documentation on setting sections in front matter; at [https://gohugo.io/content/organization/#section](https://gohugo.io/content/organization/#section) it says “section is determined by its location on disk and can not be specified in the front matter”, and at [https://gohugo.io/content/sections/](https://gohugo.io/content/sections/) it says “By default everything created within a section will use the content type  
that matches the section name. Section defined in the front matter have the same impact.”

Here’s my specific situation: I have a piece of content `piece-of-writing.md` and in the front matter I’m setting the section to “travel”. I want the destination URL to be `/travel/piece-of-writing.html`. If I put the file in `content/post` (where I’d like it to be) it outputs to `/post/piece-of-writing.html`, and if I put it in `content` without a section dir, it outputs to `/piece-of-writing.html`. I’ve tried setting permalinks in the config and leaving it out (since I’m using the default permalink arrangement).

---

<div class="post-metadata">

**Author:** ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)\
**Post date:** [May 25, 2016, 7:15pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/6 "2016-05-25T19:15:31Z")

</div>

First, the docs at your first link are wrong. The second link is correct.

Second, there’s two concepts at play here: output location and template selection.

The location of the file relative to the `content` folder determines its output location on the disk. You can see that behavior based on what you said in your last paragraph. You can override this behavior by setting the `url` field in the front matter.

The `section` or `type` is mainly used (at least the way I use it) for template selection. You can override the default section/type by setting the `section` or `type` field in the front matter.

_ **UPDATE** : My statement above is incorrect. You can only override the type, not the section._

---

<div class="post-metadata">

**Author:** ![doesntgolf](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@doesntgolf](https://discourse.gohugo.io/u/doesntgolf)\
**Post date:** [May 26, 2016, 4:02pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/7 "2016-05-26T16:02:36Z")

</div>

I appreciate the help @mooreason! It seemed to me that in Steve’s post above he’s specifically saying that setting section in the front matter _would_ reflect in the destination URL as OP was asking about. (“You can specify the section in the front matter and it would work the exact same way. No permalinks needed.”)

I was hoping I was running into a bug, or I was doing something wrong, but if that’s not the case I’m a bit bummed. I can make a pull request to correct the docs at [https://gohugo.io/content/organization/#section](https://gohugo.io/content/organization/#section), and if indeed setting section in front matter will never reflect in destination URLs, I’d think that should be documented somewhere too and if anyone wants to point out where, I’d be happy to make a pull request for that as well.

---

<div class="post-metadata">

**Author:** ![tjholowaychuk](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@tjholowaychuk](https://discourse.gohugo.io/u/tjholowaychuk)\
**Post date:** [March 10, 2017, 7:40pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/8 "2017-03-10T19:40:30Z")

</div>

Not sure what I’m doing wrong but I have:

```auto
taxonomies:
  doc: "docs"
permalinks:
  doc: /docs/:section/:slug

```

To display /docs/PRODUCT/TOPIC but it seems to not work, is it not supported for taxonomies?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 10, 2017, 7:53pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/9 "2017-03-10T19:53:31Z")

</div>

Permalinks is a global setting, and it wouldn’t make sense/or be possible to include taxonomies in it.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 10, 2017, 9:40pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/10 "2017-03-10T21:40:29Z")

</div>

> [@tjholowaychuk](#):
>
> To display /docs/PRODUCT/TOPIC but it seems to not work, is it not supported for taxonomies

Hey @tjholowaychuk, is your source organization for content the same as what we discussed before?

If so, remember that taxonomies work independent of section. So, in order to get all the `.md` files in your `content/docs` to be part of a specific taxonomy, you’d have to declare this specifically in the front matter of each content file; e.g.—

```auto
---
docs: [product, topic]
---

```

Both `product` and `terms` will show up as terms in a taxonomy terms list (i.e., as two items in `yoursite.com/docs/`).

This specific content file will show up as part of a taxonomy list at `yoursite.com/docs/product` and `yoursite.com/docs/topic`. This is why the permalink isn’t working, since taxonomies are largely just a matter of default behavior, so there technically is no “section” in this case.

Does that help?

---

<div class="post-metadata">

**Author:** ![tjholowaychuk](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@tjholowaychuk](https://discourse.gohugo.io/u/tjholowaychuk)\
**Post date:** [March 10, 2017, 10:43pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/11 "2017-03-10T22:43:56Z")

</div>

It seems really close to what I wanted, I have `docs: ["Apex Ping"]` in my ./content/doc/apex-ping/\*.md files, and I just tried renaming that dir to “docs” but it 404s on [http://localhost:3000/docs/apex-ping/alerts/](http://localhost:3000/docs/apex-ping/alerts/) (previous [http://localhost:3000/doc/apex-ping/alerts/](http://localhost:3000/doc/apex-ping/alerts/) worked).

Thanks again!

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 13, 2017, 7:02pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/12 "2017-03-13T19:02:55Z")

</div>

> [@moorereason](#):
>
> The section or type is mainly used (at least the way I use it) for template selection. You can override the default section/type by setting the section or type field in the front matter.

Really? I’ve been doing this all wrong then…and definitely need some clarity on this for the docs. I’ve made multiple edits so that it consistently says that users _cannot_ define section in front matter but _can_ define type…with the idea that Hugo’s assumes they are one in the same if not otherwise specified on a per-content-file-front-matter basis.

---

<div class="post-metadata">

**Author:** ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)\
**Post date:** [March 13, 2017, 7:32pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/13 "2017-03-13T19:32:33Z")

</div>

@rdwatters, you’re correct. My previous statement is wrong. You can only override the `type`, not the `section`.

---

<div class="post-metadata">

**Author:** ![Jonarod](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jonarod/32/5075_2.png) [@Jonarod](https://discourse.gohugo.io/u/Jonarod)\
**Post date:** [November 29, 2017, 8:16pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/14 "2017-11-29T20:16:55Z")

</div>

Hey !

> You can only override the `type`, not the `section`  
> Is this assertion still up to date ?

As of today I have a flat directory structure like :

content /  
|— my-post-1.md  
|— my-post-2.md  
|— my-post-3.md  
|— About.md

What I need is to be able to set the section to be used within each posts’s frontmatter like:  
`permalink: /post/:title`  
`permalink: /:title`

which would result the same as physically moving around my posts in a `/posts/` directory (which I would prefer no doing for obvious reasons: I don’t want to manage some content 5 levels deep !!! Who on earth would do that ?

So, I don’t really care about how you would call such parameter : `permalink` / `section` / `url` / `whatever`, but is this possible to not follow the directory pattern ?

Thanks !

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [December 11, 2017, 4:45pm UTC](https://discourse.gohugo.io/t/does-hugo-support-categories-in-the-permalink/984/15 "2017-12-11T16:45:44Z")

</div>

Have you tried just putting `url` in a post’s front matter? You can configure entire sections at once in your site `config` as well…
