# Change the root of a taxonomy

**URL:** <https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021>\
**Category:** support\
**Created:** [August 5, 2019, 3:42pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021 "2019-08-05T15:42:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yktoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yktoo/32/9252_2.png) [@yktoo](https://discourse.gohugo.io/u/yktoo)\
**Post date:** [August 5, 2019, 3:42pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/1 "2019-08-05T15:42:00Z")

</div>

I’m a bit lost in Hugo’s templating rules. I have blog posts under `/content/blog/` so they appear at `<base_url>/blog/...` - which is what I want.

Is it possible to have tags also nested under `blog`, i.e. the term page would then be at `<base_url>/blog/tags/` and list pages at `<base_url>/blog/tags/<my_tag>/` ?

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [August 5, 2019, 4:07pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/2 "2019-08-05T16:07:00Z")

</div>

Try setting the tags permalink in your `config.toml`

```nohighlight
[permalinks]
  tags = "/blog/tags/:title/"

```

---

<div class="post-metadata">

**Author:** ![yktoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yktoo/32/9252_2.png) [@yktoo](https://discourse.gohugo.io/u/yktoo)\
**Post date:** [August 5, 2019, 5:42pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/3 "2019-08-05T17:42:42Z")

</div>

Thanks @zwbetz, it worked out for the list pages, however not for the terms page, it’s still at `ROOT/tags/`. Should I then add an `_index.md` and set a URL manually, or is there a better way?

---

<div class="post-metadata">

**Author:** ![yktoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yktoo/32/9252_2.png) [@yktoo](https://discourse.gohugo.io/u/yktoo)\
**Post date:** [August 5, 2019, 5:57pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/4 "2019-08-05T17:57:16Z")

</div>

I’ve sorted it out. The only changes required were:

1. Set `tags = "/blog/tags/:title/"` in the `Permalinks` section of the site config file
2. Create a file `/content/blog/tags/_index.md` with the following front matter:

```auto
title: Blog tags
type: tags
layout: terms
# The below creates a redirect at /tags to this page.
# Not really required but neat
aliases:
    - /tags

```

3. Use `.Site.Taxonomies.tags` instead of `.Data.Terms` in the terms template (`/layout/tags/terms.html`)
4. In order for `aliases` from the front matter to work, you need to disable default page generation at `/tags` because it will overwrite the redirect page otherwise. The simplest way to achieve that I managed to find is to create an **empty** template file `/layouts/tags/empty.html` and configure the page at `/tags` to use it by creating `/content/tags/_index.md` with the following content:

```auto
---
layout: empty
---

```

Phew.

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [August 5, 2019, 6:03pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/5 "2019-08-05T18:03:04Z")

</div>

Good deal. And for clarity for future readers: Point (1) sets the permalink of individual tags pages. Points (2) and (3) set the permalink of the tags list page.

---

<div class="post-metadata">

**Author:** ![yktoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yktoo/32/9252_2.png) [@yktoo](https://discourse.gohugo.io/u/yktoo)\
**Post date:** [August 6, 2019, 11:43am UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/6 "2019-08-06T11:43:49Z")

</div>

There’s still one problem though. I see that tag terms and lists get now generated in both `/tags/` and `/blog/tags/`, effectively duplicating all pages. Also peculiar that all links on both terms pages point at the correct tags under `/blog/tags/`.

How can I get rid of this duplication?

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [August 6, 2019, 12:05pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/7 "2019-08-06T12:05:14Z")

</div>

Delete you `public` dir then rebuild. The old files are hanging around.

---

<div class="post-metadata">

**Author:** ![yktoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yktoo/32/9252_2.png) [@yktoo](https://discourse.gohugo.io/u/yktoo)\
**Post date:** [August 6, 2019, 12:11pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/8 "2019-08-06T12:11:05Z")

</div>

Thanks! You’re right, after a clean rebuild all list pages are gone.

Yet, `/tags/index.html` is still there. Can I disable it or otherwise turn it into a redirect page?

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [August 6, 2019, 1:23pm UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/9 "2019-08-06T13:23:41Z")

</div>

I’m not sure. Maybe others on here can help you.

---

<div class="post-metadata">

**Author:** ![yktoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yktoo/32/9252_2.png) [@yktoo](https://discourse.gohugo.io/u/yktoo)\
**Post date:** [August 15, 2019, 8:08am UTC](https://discourse.gohugo.io/t/change-the-root-of-a-taxonomy/20021/10 "2019-08-15T08:08:03Z")

</div>

I think I’ve figured that out. I’ve updated my solution post.  
On a side note, IMHO it would be nice to have a simpler/cleaner way of reconfiguring taxonomy URLs.
