Internal Tags show up in post

I am working on customizing one of the default themes and I’m seeing something strange.

When I use {{tags}} in my post.hbs, I get what I expect, all of the public tags. However. if I do:

{{#each tags}}
  <a class="gh-article-tag" href="{{this.url}}" style="--tag-color: {{this.accent_color}}">{{this.name}}</a>
{{/each}}

I am getting back public AND internal tags. Any way to add a visibility filter when using tags in a loop like this. I tried

{{#each tags visibility="public"}}

but it did not have any affect. Here’s the actual code. For debugging I added {{tags}} and I’ve added {{this.visibility}} inside the loop. My end goal is to only have the loop.

<div class="all-tags">
  {{tags}}
  <hr />
  {{#each tags visibility="public"}}
    {{this.visibility}}
    <a class="gh-article-tag" href="{{this.url}}" style="--tag-color: {{this.accent_color}}">{{this.name}}</a>
  {{/each}}
</div>

and here’s how it looks. You can see above the <hr> tag, is {{tags}} and below the <hr> is where I am looping over {{tags}}

image

Gscan should be telling you not to use the each helper - Ghost uses {{foreach}}.

3 Likes

Gotcha, thanks for quick reply @Hannah!

Yup, I changed it to a foreach and it works as expected. :smiley:

1 Like