# Tag page : group posts by private tags

**URL:** <https://forum.ghost.org/t/tag-page-group-posts-by-private-tags/21470>\
**Category:** Themes\
**Created:** [April 2, 2021, 3:13pm UTC](https://forum.ghost.org/t/tag-page-group-posts-by-private-tags/21470 "2021-04-02T15:13:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![julienb](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/julienb/32/12440_2.png) [@julienb](https://forum.ghost.org/u/julienb)\
**Post date:** [April 2, 2021, 3:13pm UTC](https://forum.ghost.org/t/tag-page-group-posts-by-private-tags/21470/1 "2021-04-02T15:13:43Z")

</div>

Hi,

I’m working on my `tag.hbs` template (the tag page) and I’m trying to group my posts by private tags (I’m trying to use public tags as main categories and private tags as subcategories).

The result I would like, for example for the public tag “Food” at the url `/tag/food`

> ## Tag: Food
> 
> ### Burger (private tag)
> 
> Article 1  
> Article 2  
> Article 3
> 
> ### Pizza (also a private tag)
> 
> Article 4  
> Article 5  
> Article 6

I tried to do the following :

```auto
        {{#get 'tags'}}
            {{#foreach tags visibility="internal"}}
                <h2>{{ description }}</h2> <!-- a private tag -->
                <div>
                    {{#get "posts" limit="all" include="tags" filter="tags:[{{@root.tag.slug}},{{slug}}]"}}
                    
                        {{#foreach posts}}
                            {{> "card"}} {{!-- partials/card.hbs --}}
                        {{/foreach}}
                    {{/get}}
                </div>
            {{/foreach}}
        {{/get}}

```

But `{{@root.tag.slug}}` seems to be empty when I use it inside the `get`… However if I use it outside (like to print it) it shows well the tag slug.

Would someone have an idea how to solve it ? I searched everywhere but no clue 🤔

Thanks in advance,

Julien

---

<div class="post-metadata">

**Author:** ![John](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/john/32/29288_2.png) [@John](https://forum.ghost.org/u/John)\
**Post date:** [April 2, 2021, 3:27pm UTC](https://forum.ghost.org/t/tag-page-group-posts-by-private-tags/21470/2 "2021-04-02T15:27:57Z")

</div>

Nested get-helpers is a bit of a 😬 usecase which is likely to affect performance. I personally wouldn’t approach it like this, I think you’d be better off hard-coding it, if it isn’t going to change often - or making clientside requests directly with the Content API.

As a punt/guess: try replacing `@root.tag.slug` with `../tag.slug`

---

<div class="post-metadata">

**Author:** ![julienb](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/julienb/32/12440_2.png) [@julienb](https://forum.ghost.org/u/julienb)\
**Post date:** [April 2, 2021, 3:53pm UTC](https://forum.ghost.org/t/tag-page-group-posts-by-private-tags/21470/3 "2021-04-02T15:53:53Z")

</div>

Thank you for your quick reply.

> [@John](#):
>
> As a punt/guess: try replacing `@root.tag.slug` with `../tag.slug`

I already tried it :

```auto
{{#get "posts" limit="all" include="tags" filter="tags:[{{../tag.slug}},{{slug}}]"}}

```

but I got this error :

```auto
Parse error on line 1: ../tag.slug ^ Expecting 'DOLLAR', 'STAR', 'IDENTIFIER', 'SCRIPT_EXPRESSION', 'INTEGER', 'END', got 'DOT_DOT'

```

> or making clientside requests directly with the Content API.

Yes, but as it’s clientside, it wouldn’t be good for the SEO, would it ?

---

<div class="post-metadata">

**Author:** ![John](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/john/32/29288_2.png) [@John](https://forum.ghost.org/u/John)\
**Post date:** [April 2, 2021, 4:45pm UTC](https://forum.ghost.org/t/tag-page-group-posts-by-private-tags/21470/4 "2021-04-02T16:45:08Z")

</div>

Oop, I forgot `tag.slug` is not a thing - it would have to be `primary_tag.slug` if you want something singular, otherwise you’d have to parse out the array that is `tags`

> Yes, but as it’s clientside, it wouldn’t be good for the SEO, would it ?

_usually_ tag index pages don’t do very will in search engines anyway, so it depends what you want to optimise for.

A middleground is what Buffer do on their blog, which has similar tag filters, is to load the first page of posts serverside, but then load any remaining posts on the different tabs/filters using clientside JS

White section at the bottom here:

> **[Buffer Resources](https://buffer.com/resources/)**
>
> Buffer’s social media marketing blog covers the latest social media tools, analytics, and strategies for Twitter, Facebook, and more...

---

<div class="post-metadata">

**Author:** ![julienb](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/julienb/32/12440_2.png) [@julienb](https://forum.ghost.org/u/julienb)\
**Post date:** [April 2, 2021, 5:12pm UTC](https://forum.ghost.org/t/tag-page-group-posts-by-private-tags/21470/5 "2021-04-02T17:12:55Z")

</div>

Thank you, I’ll have a look !
