Skip to main content

Quick Tip: The Tag loop in a Ghost theme

Official theme documentation is still evolving however the forums continue to be the best place to learn from fellow Ghost developers.

Recently while trying to wrap the tags, the code given on the official documentation did not work as expected. But thanks to the help from forum, you would find below an example code to detect if tags exists for a post and if they do, then it displays them in a nice unordered list.

Conversation on Ghost.org Forum

{{#if tags}}
<ul class="tags">
    {{#foreach tags}}
    <li class="tag">{{name}}</li>
    {{/foreach}}
</ul>
{{/if}}

Have any other useful code to share? Do email us at me@harishchouhan.com with your details.

Buffer

Did you like what you read?

Sign Up and Get Free Email Updates. We won’t spam you; we just want to keep you up-to-date with news about Ghost

Comments

comments powered by Disqus