# Section-based tags

**URL:** <https://discourse.gohugo.io/t/section-based-tags/3069>\
**Category:** support\
**Created:** [April 7, 2016, 1:30am UTC](https://discourse.gohugo.io/t/section-based-tags/3069 "2016-04-07T01:30:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanna](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hanna/32/10337_2.png) [@hanna](https://discourse.gohugo.io/u/hanna)\
**Post date:** [April 7, 2016, 1:30am UTC](https://discourse.gohugo.io/t/section-based-tags/3069/1 "2016-04-07T01:30:00Z")

</div>

I want to know if it is possible to have section-based tags (or any kind of taxonomy, really.)

An example:

I have a homepage with a blog and a portfolio of work, so blog and work sections. I write a blog post about Golang and tag it ‘golang’. I also make an app using Golang, include it in my work portfolio, and then tag it ‘golang’. I don’t want to see both the post and the portfolio piece when I look at a /tags/golang - ideally, I would have a URL that looks like /blog/tags/golang with its own view specific to blog posts and then a URL that looks like /work/tags/golang with its own view specific to portfolio pieces. Is this possible in Hugo?

---

<div class="post-metadata">

**Author:** ![mikeaja](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mikeaja](https://discourse.gohugo.io/u/mikeaja)\
**Post date:** [April 7, 2016, 8:47am UTC](https://discourse.gohugo.io/t/section-based-tags/3069/2 "2016-04-07T08:47:57Z")

</div>

I was working on a blog with tags not entered as front matter. Something like automatic tags. Idea was a Hugo driven blog with each post as a simple text file only, nothing else (no front matter, no shortcodes, no HTML in content), but that would operate like a standard blog.

The method I used could be a starting point for your issue. Using the _.RelPermalink_ variable along with the _split_ template function to create tages based on content location.

In my case this meant the blog posts needed to have a foolder hierachy matching the category / subject / tag /etc, and it also meant cross-tagging a post (with two different subjects) was not possible. But this sounds like what you want.

---

<div class="post-metadata">

**Author:** ![Bin951](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bin951/32/5003_2.png) [@Bin951](https://discourse.gohugo.io/u/Bin951)\
**Post date:** [March 24, 2018, 3:48pm UTC](https://discourse.gohugo.io/t/section-based-tags/3069/3 "2018-03-24T15:48:01Z")

</div>

same problem I met as @hanna .

I have tag `gohugo` for post in section-A and Section-B, when I click the `gohugo` tag in section-A, I would like to list all pages tagged `gohugo` in section-A; when click `gohugo` tag on a section-B page, list all pages tagged `gohugo` in section-B.

Is it possible or what kind of method should I use?

---

<div class="post-metadata">

**Author:** ![Bin951](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bin951/32/5003_2.png) [@Bin951](https://discourse.gohugo.io/u/Bin951)\
**Post date:** [March 24, 2018, 6:50pm UTC](https://discourse.gohugo.io/t/section-based-tags/3069/5 "2018-03-24T18:50:48Z")

</div>

@Mikhail thanks a lot for your quick help.

I have Partial template `tags.html` as follows, and works fine.

```auto
<div class="tag-list">
{{ range .Params.tags }}
<a href="{{ relURL (print "/tags/" . | urlize) }}" class="tag-link">{{ . }}</a>
{{ end }}
</div>

```

After that I tried your suggestion(also read the gohugo docs for `eq` )

```auto
<div class="tag-list">
{{ range .Params.tags }}
{{ if eq .Section "sectionname" }}
<a href="{{ relURL (print "/sectionname/tags/" . | urlize) }}" class="tag-link">{{ . }}</a>
{{ end }}
{{ end }}
</div>

```

executing “theme/sectionname/list.html” at \<partial “tags.html” …\>: error calling partial: template: theme/partials/tags.html:6:17: executing “theme/partials/tags.html” at \<.Section\>: can’t evaluate field Section in type string.

if `{{ if eq $.Section "sectionname" }}`  
no ERRO alert. but I still cant get URL like /sectionname/tag/…

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [March 24, 2018, 7:35pm UTC](https://discourse.gohugo.io/t/section-based-tags/3069/6 "2018-03-24T19:35:47Z")

</div>

Sorry, I did not understand you correctly. If you want to have different lists of pages at address `/tags/golang/`, then this is impossible. This list is generated by the taxonomy mechanism. You need to create an additional taxonomy (tags2, labels, etc) which will have a different address `/tags2/golang/`.

---

<div class="post-metadata">

**Author:** ![Bin951](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bin951/32/5003_2.png) [@Bin951](https://discourse.gohugo.io/u/Bin951)\
**Post date:** [March 25, 2018, 12:59am UTC](https://discourse.gohugo.io/t/section-based-tags/3069/7 "2018-03-25T00:59:25Z")

</div>

@Mikhail thank you for kind help.

So the conclusion for this topic should be IMPOSSIBLE at present time. [Ever I was thinking about the possibility of this way : [section-A.example.com/tags/golang](http://section-A.example.com/tags/golang), [section-B.example.com/tags/golang](http://section-B.example.com/tags/golang) to output pages list respectively. maybe make the site more complicated?]

@bep can I consider this as a feature request?

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 25, 2018, 2:20am UTC](https://discourse.gohugo.io/t/section-based-tags/3069/8 "2018-03-25T02:20:36Z")

</div>

you can of course do _[example.com/section-A/tags](http://example.com/section-A/tags)_, _[example.com/section-B/tags](http://example.com/section-B/tags)_, …

You just need to design those templates manually… They would be like any other section page (not taxonomyTerm pages).

You can even go further, and have: _[example.com/section-A/tags/tag-foo](http://example.com/section-A/tags/tag-foo)_… but things will start getting messy there… you will need to create a filter list of posts with tag _tag-foo_ specific to that section-A. So you will need a hard-coded template for each _section_ X _tag_.

---

<div class="post-metadata">

**Author:** ![Bin951](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bin951/32/5003_2.png) [@Bin951](https://discourse.gohugo.io/u/Bin951)\
**Post date:** [March 25, 2018, 3:17am UTC](https://discourse.gohugo.io/t/section-based-tags/3069/9 "2018-03-25T03:17:01Z")

</div>

@kaushalmodi thank you for quick feedback and kind help.

So the good news and bad news to the topic 😄

> [@kaushalmodi](#):
>
> you can of course do [example.com/section-A/tags](http://example.com/section-A/tags), [example.com/section-B/tags](http://example.com/section-B/tags), …
> 
> You just need to design those templates manually… They would be like any other section page (not taxonomyTerm pages).

Yeah, taking your suggestion into consideration.

> [@kaushalmodi](#):
>
> You can even go further, and have: [example.com/section-A/tags/tag-foo…](http://example.com/section-A/tags/tag-foo%E2%80%A6)

Seems going forward to the target 😄 though I still try to find out what method I should use for working it out.

> [@kaushalmodi](#):
>
> but things will start getting messy there… you will need to create a filter list of posts with tag tag-foo specific to that section-A

Yes, I could understand it and thanks for instruction.

> [@kaushalmodi](#):
>
> So you will need a hard-coded template for each section X tag.

Oh, ever I guess this topic could be solved by `breadcrumb` template, but didn’t try it out.  
When I see the word hard-coded, got a little headache 😿
