how to display list of tags in ghost blog?
Asked Answered
B

1

5

I am unable to display list of available tags in a sidebar, in ghost blog.

I am tag.hbs file with the below code.

    <header class="main-header tag-head {{#if tag.image}}" style="background-image: url({{tag.image}}){{else}}{{#if @blog.cover}}" style="background-image: url({{@blog.cover}}){{else}}no-cover{{/if}}{{/if}}">
    <nav class="main-nav overlay clearfix">
        <a class="back-button icon-arrow-left" href="{{@blog.url}}">Home</a>
    </nav>
    <div class="vertical">
        <div class="main-header-content inner">
            <h1 class="page-title">{{tag.name}}</h1>
            <h2 class="page-description">
                {{#if tag.description}}
                    {{tag.description}}
                {{else}}
                    A {{pagination.total}}-post collection
                {{/if}}
            </h2>
        </div>
    </div>
</header>

{{! The main content area on the homepage }}
<main class="content" role="main">
    <div class="container">
        <div class="row-fluid">
            <div class="col-md-12">
                {{! The tag below includes the post loop - partials/loop.hbs }}
                {{> "loop"}}
            </div>
        </div>
    </div>

</main>
{{> myfooter colour='ec-teal' inverse='true'}}

And this is how I am including it in my post.hbs file

<div class="col-md-4">
   <div class="row tags-row">
         <h3> TAGS </h3>
         {{#tag}}{{/tag}}
    </div>
</div>
Bine answered 31/8, 2016 at 10:1 Comment(1)
Problem solved: All I did was updated my code in post.hbs and changed {{#tag}}{{/tag}} to only {{tags}} and that resolved the issue.Bine
P
11

make sure you have activated the option api you can use this helper for example:

if you get tags use

{{#get "tags"}}
{{#foreach tags}}
//Add html for each tag here
{{/foreach}}
{{/get}}

if you get al tags use this:

{{#get "tags" limit="all"}}
{{#foreach tags}}
//Add html for each tag here
{{/foreach}}
{{/get}}

if you get tags with count post

{{#get "tags" include="count.posts"}}
{{#foreach tags}}
//Add html for each tag here
{{/foreach}}
{{/get}} 

i hope that some this examples respond your question

Piecrust answered 26/9, 2016 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.