In Jekyll, how can I create a tag archive for pages?

Tom Johnson

I'm using tags on pages in Jekyll, like this:

---
title: Sample page
permalink: /sample/
tag: news
---

On my homepage, I have different sections that aggregate pages by tag, like this:

{% assign counter = '0' %}
{% for page in site.pages %}
{% for tag in page.tags %}
{% if tag == "news" and counter < '3' %}
{% capture counter %}{{ counter | plus:'1' }}{% endcapture %}
<li><a href="{{ page.permalink | prepend: site.baseurl }}">{{page.title}}</a></li>
<div class="summary">{{page.summary}}</div>
{% endif %}
{% endfor %}
{% endfor %}

This loop limits the news-tagged pages to 3, but I might have 10+ pages with the tag of "news." I want to include a "View all" tag at the bottom, so that users can see a complete list of all pages matching that tag.

I realize I could manually create a page and add similar code but without a limit to get all the pages. However, that's kind of tedious. I'd rather have Jekyll auto-generate a tag archive by default. I think Jekyll has a concept of generators, but I'm not sure how to implement a tag page generator.

How can I dynamically generate tag archive pages without creating and entering code on each page?

w1n78

check out jekyll-archives plugin. i just found out about this and am able to generate categories and tags pages. it does increase compile time coz of the number of categories and tags i have but it does what i need it to do. https://github.com/jekyll/jekyll-archives

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How do I create an IF statement based on a Jekyll category?

分類Dev

How can I see all versions of a package that are available in the archive?

分類Dev

Liquid syntax error for 'gist' tag with github-pages gem for Jekyll

分類Dev

jekyll-seo-tag doesn't work within Github Pages

分類Dev

How to paginate categories in Jekyll with Github Pages?

分類Dev

How can I render a <template /> tag with react?

分類Dev

I use jquery in github pages which use jekyll to generate website

分類Dev

How can i control the number of pages to be print using javascript?

分類Dev

How can I "store" an object or JSON across content pages in Xamarin?

分類Dev

How can I find all the unused and uncategorized pages and images in MediaWiki?

分類Dev

How can I alter livejs to run on PHP pages?

分類Dev

How can I incorporate Python scripts into web pages?

分類Dev

how can i set different menus on different pages in wordpress?

分類Dev

How can I integrate ASP pages and queries into an iOS app?

分類Dev

How can I print a PDF document on multiple pages?

分類Dev

Can I select which file to archive in shutil?

分類Dev

How do I stop KeePass from automatch-ing all pages, when using the tag/title "Google"

分類Dev

Jekyll: Can I combine collections and data files?

分類Dev

How can I use regex to construct an API call in my Jekyll plugin?

分類Dev

How can I properly create /dev/dvd?

分類Dev

How can I create a pair type in go?

分類Dev

How can I create STPCard stripe ios?

分類Dev

How can I create a wavy shape CSS?

分類Dev

How I can create a dynamically label change?

分類Dev

How can I create nested group_by?

分類Dev

How Can I Create A Custom Property Type

分類Dev

How can I get SSRS to create subheadings?

分類Dev

How can I create text with an engraved effect?

分類Dev

How can I create an interface for a collection of objects?

Related 関連記事

  1. 1

    How do I create an IF statement based on a Jekyll category?

  2. 2

    How can I see all versions of a package that are available in the archive?

  3. 3

    Liquid syntax error for 'gist' tag with github-pages gem for Jekyll

  4. 4

    jekyll-seo-tag doesn't work within Github Pages

  5. 5

    How to paginate categories in Jekyll with Github Pages?

  6. 6

    How can I render a <template /> tag with react?

  7. 7

    I use jquery in github pages which use jekyll to generate website

  8. 8

    How can i control the number of pages to be print using javascript?

  9. 9

    How can I "store" an object or JSON across content pages in Xamarin?

  10. 10

    How can I find all the unused and uncategorized pages and images in MediaWiki?

  11. 11

    How can I alter livejs to run on PHP pages?

  12. 12

    How can I incorporate Python scripts into web pages?

  13. 13

    how can i set different menus on different pages in wordpress?

  14. 14

    How can I integrate ASP pages and queries into an iOS app?

  15. 15

    How can I print a PDF document on multiple pages?

  16. 16

    Can I select which file to archive in shutil?

  17. 17

    How do I stop KeePass from automatch-ing all pages, when using the tag/title "Google"

  18. 18

    Jekyll: Can I combine collections and data files?

  19. 19

    How can I use regex to construct an API call in my Jekyll plugin?

  20. 20

    How can I properly create /dev/dvd?

  21. 21

    How can I create a pair type in go?

  22. 22

    How can I create STPCard stripe ios?

  23. 23

    How can I create a wavy shape CSS?

  24. 24

    How I can create a dynamically label change?

  25. 25

    How can I create nested group_by?

  26. 26

    How Can I Create A Custom Property Type

  27. 27

    How can I get SSRS to create subheadings?

  28. 28

    How can I create text with an engraved effect?

  29. 29

    How can I create an interface for a collection of objects?

ホットタグ

アーカイブ