gevorg
gevorg

Reputation: 5065

How can I add proper tag support for jekyll blog hosted on GitHub?

Problem

Recently I added tag support for my personal blog, but I am not happy with a way that it was done.

Blog uses with , so my solution has many limitations that platform comes with.

In order to create tag javascript I created file tag/javascript/index.html with following content:

---
layout: tag
tag: javascript
---

And it in my tag layout file I have following code:

---
layout: default
---
<div class="tag-header">
    posts related to <strong>{{ page.tag }}</strong>
</div>
{% for post in site.posts %}
{% if post.tags contains page.tag %}
<section class="post">
    <header>
        <a href="{{ post.url }}">{{ post.title }}</a>
    </header>
    <time>
        {{ post.date | date_to_string }}
    </time>
    <summary>
        {% if post.excerpt %}
        {{ post.excerpt }}
        <a href="{{ post.url }}">read more</a>
        {% endif %}
    </summary>
    <div class="tags">
        {% for tag in post.tags %}
        <span>
            <a href="/tag/{{ tag }}">#{{ tag }}</a>
        </span>
        {% endfor %}
    </div>
</section>
{% endif %}
{% endfor %}

Result is something like this posts related to javascript.

Question

How can I automate tag creation process, so it does not require manual tag file creation (tag/javascript/index.html from sample)?

Notice

I have read An easy way to support tags in a jekyll blog already, and the only working solution for was this one, which I don't like, because it puts all tags in one page.

Additionally note that I am using , so custom plugin is not an option.

You can find full sources here.

Upvotes: 1

Views: 84

Answers (1)

David Jacquel
David Jacquel

Reputation: 52829

Current Jekyll (3.1.x) cannot generate tag page automatically. You need to use a custom plugin. But you don't want to.

Why ? It's not so difficult to change deployment process on github pages.

You can store you code in master and you generated page in gh-pages. This answer will give your more information on how to do it.

Upvotes: 2

Related Questions