Themes

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 [email protected] with your details.

Discussion

Discover Ghost newsletter

Ghost tips and new themes, in your inbox.

New tutorials, platform updates, and theme releases. Sent only when there is something worth reading.

Thanks for subscribing. Check your inbox to confirm.