Add plugin for generating tag pages automatically#84
Open
borting wants to merge 1 commit intoLeNPaul:gh-pagesfrom
Open
Add plugin for generating tag pages automatically#84borting wants to merge 1 commit intoLeNPaul:gh-pagesfrom
borting wants to merge 1 commit intoLeNPaul:gh-pagesfrom
Conversation
This plugin automatically generates tags after saving posts if jekyll
server is running at background. The tag pages are stored in the tags/
dir, and you can add those pages to commits then push them to GitHub.
To enable this plugin, please do the following steps:
1. Create a dir named 'tags' under the root dir.
2. Create a layout, named `_layouts/tag.html,` for tag pages.
3. Comment out the first `return` statement in the plugin.
4. Update `_layouts/post.html` to show tag list on posts.
After enablinf this plugin, start jekyll server at local, and the server
will parse all posts and generate tag pages to the `tags/` dir. The tag
pages are also generated on-the-fly after saving posts if jekyll server
is running at background.
* Here is an example of `_layouts/tag.html` for tag page layout:
---
layout: default
---
<h1>
Tag: {{ page.tag }}
</h1>
<ul>
{% for post in site.posts %}
{% if post.tags contains page.tag %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
({{ post.date | date_to_string }})<br>
</li>
{% endif %}
{% endfor %}
</ul>
* Here is an example of `_layouts/post.html` for showing tag list:
--- a/_layouts/post.html
+++ b/_layouts/post.html
@@ -30,6 +30,16 @@ layout: default
{% endif %}
</span>
+<span>
+ {% if page.tags != null %}
+ {% for tag in page.tags %}
+ {% capture tag_name %}{{ tag }}{% endcapture %}
+ <a href="/tag/{{ tag_name }}"><code class="highligher-rouge"><nobr>{{ tag_name }}</nobr></code></a>
+ {% endfor %}
+ {% endif %}
+</span>
+
{% include social-sharing.html %}
{% include related-posts.html %}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This plugin automatically generates tags after saving posts if jekyll
server is running at background. The tag pages are stored in the tags/
dir, and you can add those pages to commits then push them to GitHub.
To enable this plugin, please do the following steps:
_layouts/tag.html,for tag pages.returnstatement in the plugin._layouts/post.htmlto show tag list on posts.After enablinf this plugin, start jekyll server at local, and the server
will parse all posts and generate tag pages to the
tags/dir. The tagpages are also generated on-the-fly after saving posts if jekyll server
is running at background.