2017-07-14 14 views
0

私のジーケルページには、3種類の投稿があります:ゲーム、ビジネス、考え、各投稿タイプがタグで分類されています。最近の投稿をジキルに投稿タグで一覧表示するにはどうすればよいですか?

私はindex.htmlのコードを使用しています。これは自分のサイトの最新投稿を投稿して、それぞれの投稿を 'post.title'、 'post.date'、 'post'でリストに表示します。タグ '、'ページサマリー(コンテンツ) 'の情報が含まれます。

私のサイトは、投稿カテゴリ(ゲーム、ビズのレビュー、思考)ごとに異なるページを持っていますが、私はindex.html(以下のコード)で使用したこの表示形式を前面それぞれの異なるページのページ(ゲーム、ビズのレビュー、思考)。

<div class="home"> 

    <div class="post-list"> 
     {% for post in site.posts limit:10 %} 


    <h2><a class="post-link" href="{{ post.url | remove: "/" }}">{{ post.title }}</a></h2> 
     <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}/
      {% for tag in post.tags %} 

       <a href="{{ "tag_" | append: tag | append: ".html"}}">{{tag}}</a>{% unless forloop.last %}, {% endunless%} 

       {% endfor %}</span> 
     <p>{% if page.summary %} {{ page.summary | strip_html | strip_newlines | truncate: 160 }} {% else %} {{ post.content | truncatewords: 50 | strip_html }} {% endif %}</p> 

     {% endfor %} 

    </div> 
</div> 

さらに明確に理解するために、私の質問を理解するのに役立つ写真をいくつか挙げました。

事前にコミュニティに感謝します。


index.html showing recent postings(of all kinds) from the sites

I want the below listing to show the recent postings only from the postings with game tags.

答えて

0

すべてのタグから最初の10枚のポストの上にループ現在の繰り返し処理:

{% for post in site.posts limit:10 %} 

あなたは "ゲーム" で最初の10枚のポストを反復処理することができますタグを最初にフィルタリングしてください:

{% assign game_posts = site.posts | where_exp: "post", "post.tags contains 'game'" %} 
{% for post in game_posts limit:10 %} 

あなたはwhere_expフィルタの少なくともジキルのV3.2.0が必要になります。

あなたは、各タグのマークアップのチャンクを再利用することを計画しているので、私はレイアウトに変換し、それを使用して各ページの前付変数としてタグを持つに探してお勧めします。

関連する問題