Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display list of tags in ghost blog?

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>
like image 488
Nauman Tanwir Avatar asked Aug 31 '16 10:08

Nauman Tanwir


People also ask

How do you add tags on Ghost blog?

Ghost has a flexible tagging system, which can be used to organize your content both in the Admin area and on your website. Tags can quickly be added from the Post settings menu, with a menu to select existing tags, or you can add new tags from here.

What is Ghost tagged?

A ghost tag is there to provide information: it tells you which Folders/Projects the parent tasks lives in. If the subtask has multiple parent tasks, then it has a ghost tag for each Folder/Project that the parent tasks are in.

How do I change my theme on Ghost blog?

To edit your theme files, download a copy of the theme from the Settings → Design area in Ghost Admin, then unzip the theme locally. Once the theme is unzipped, the files can be edited using an HTML editor.


1 Answers

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

like image 103
hackemate Avatar answered Sep 19 '22 03:09

hackemate