如何在幽灵博客中显示标签列表?

how to display list of tags in ghost blog?

我无法在 ghost 博客的边栏中显示可用标签列表。

我是 tag.hbs 文件,代码如下。

    <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'}}

这就是我将其包含在我的 post.hbs 文件中的方式

<div class="col-md-4">
   <div class="row tags-row">
         <h3> TAGS </h3>
         {{#tag}}{{/tag}}
    </div>
</div>

确保你已经激活了选项api你可以使用这个助手,例如:

如果你得到标签使用

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

如果你得到 al 标签,使用这个:

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

如果您获得计数为 post

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

我希望一些例子能回答你的问题