Skip to content

Commit 3664e56

Browse files
OCram85daattali
authored andcommitted
Replaces tag index plugin with native jekyll features (daattali#307)
* remove tag _gen plugin and its folder * remove deprecated tag index layout * add tag index page * link tag index page in nav bar, enable tag links by default * add button spacer in main css * fix tag links in post view * fix tag links on index and pagination * tag link instuctions removed. it's enabled as default
1 parent 22e77cf commit 3664e56

File tree

8 files changed

+50
-88
lines changed

8 files changed

+50
-88
lines changed

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030

3131
## Prerequisites
3232

33-
- You need to have a GitHub account. If you don't have one, [sign up here](https://github.com/join) - it takes one minute. This is where your website will live - if you sign up with username `johnsmith` then your website will be `http://johnsmith.github.io`.
33+
- You need to have a GitHub account. If you don't have one, [sign up here](https://github.com/join) - it takes one minute. This is where your website will live - if you sign up with username `johnsmith` then your website will be `http://johnsmith.github.io`.
3434
- It would be helpful to understand what Markdown is and how to write it. Markdown is just a way to take a piece of text and format it to look a little nicer. For example, this whole instruction set that you're reading is written in markdown - it's just text with some words being bold/larger/italicized/etc. I recommend taking 5 minutes to learn markdown [with this amazingly easy yet useful tutorial](http://markdowntutorial.com/).
3535

3636
## Build your website in 3 steps
3737

38-
Getting started is *literally* as easy as 1-2-3 :smile:
38+
Getting started is *literally* as easy as 1-2-3 :smile:
3939
Scroll down to see the steps involved, but here is a 40-second video just as a reference as you work through the steps.
4040

4141
![Installation steps](img/install-steps.gif)
@@ -142,11 +142,11 @@ image | If you want to add a personalized image to your blog post that wil
142142
share-img | If you want to specify an image to use when sharing the page on Facebook or Twitter, then provide the image's full URL here.
143143
social-share | If you don't want to show buttons to share a blog post on social media, use `social-share: false` (this feature is turned on by default).
144144
use-site-title | If you want to use the site title rather than page title as HTML document title (ie. browser tab title), use `use-site-title: true`. When set, the document title will take the format `Site Title - Site Description` (eg. `My website - A virtual proof that name is awesome!`). By default, it will use `Page Title` if it exists, or `Site Title` otherwise.
145-
layout | What type of page this is (default is `blog` for blog posts and `page` for other pages. You can use `minimal` if you don't want a header and footer)
145+
layout | What type of page this is (default is `blog` for blog posts and `page` for other pages. You can use `minimal` if you don't want a header and footer)
146146
js | List of local JavaScript files to include in the page (eg. `/js/mypage.js`)
147147
ext-js | List of external JavaScript files to include in the page (eg. `//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js`). External JavaScript files that support [Subresource Integrity (SRI)](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) can be specified using the `href` and `sri` parameters eg.<br/>`href: "//code.jquery.com/jquery-3.1.1.min.js"`<br/>`sri: "sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="`
148148
css | List of local CSS files to include in the page
149-
ext-css | List of external CSS files to include in the page. External CSS files using SRI (see `ext-js` parameter) are also supported.
149+
ext-css | List of external CSS files to include in the page. External CSS files using SRI (see `ext-js` parameter) are also supported.
150150
googlefonts | List of Google fonts to include in the page (eg. `["Monoton", "Lobster"]`)
151151
gh-repo   | If you want to show GitHub buttons at the top of a post, this sets the GitHub repo name (eg. `daattali/beautiful-jekyll`). You must also use the `gh-badge` parameter to specify what buttons to show.
152152
gh-badge | Select which GitHub buttons to display, available options are: [star, watch, fork, follow]. You must also use the `gh-repo` parameter to specify the GitHub repo.
@@ -207,7 +207,7 @@ Want your website featured here? [Contact me](http://deanattali.com/aboutme#cont
207207

208208
Beautiful Jekyll is meant to be so simple to use that you can do it all within the browser. However, if you'd like to develop locally on your own machine, that's possible too if you're comfortable with command line. Follow these simple steps set that up with Docker:
209209

210-
1. Make sure you have [Docker](https://www.docker.com/) installed.
210+
1. Make sure you have [Docker](https://www.docker.com/) installed.
211211

212212
2. Clone your repository locally.
213213

@@ -240,8 +240,6 @@ Whenever you make any changes to `_config.yml`, you must stop and re-start the s
240240

241241
Disclaimer: I personally am NOT using local development so I don't know much about running Jekyll locally. If you follow this route, please don't ask me questions because unfortunately I honestly won't be able to help!
242242
243-
Aditionally, if you choose to deploy Jekyll using a local ruby installation, you can tell Jekyll to automatically categorize your blog posts by tags. You just need to set `link-tags: true` in `_config.yml`. Jekyll will then generate a new page for each unique tag which lists all of the posts that belong to that tag.
244-
245243
## FAQ
246244
247245
Beautiful Jekyll is actively used by thousands of people with wildly varying degrees of competency, so it's impossible to answer all the questions that may arise. Below are answers to a few very common questions. Most questions that I get asked are not directly related to this theme, and instead are more general questions about Jekyll or web development. Many such questions can be answered by reading the [Jekyll documentation](http://jekyllrb.com/) or simply by Googling.

_config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ navbar-links:
2929
- Learn markdown: "http://www.markdowntutorial.com/"
3030
- GitHub Pages: "https://pages.github.com/"
3131
Author's home: "http://deanattali.com"
32+
Tags: "tags"
3233

3334
# Image to show in the navigation bar - image must be a square (width = height)
3435
# Remove this parameter if you don't want an image in the navbar
@@ -152,7 +153,7 @@ defaults:
152153
show-avatar: true
153154

154155
# Use tags pages (not recommended if you are deploying via GitHub pages, only set to true if deploying locally with ruby)
155-
link-tags: false
156+
link-tags: true
156157

157158
# Exclude these files from production site
158159
exclude:

_layouts/post.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{% assign gh_split = page.gh-repo | split:'/' %}
1313
{% assign gh_user = gh_split[0] %}
1414
{% assign gh_repo = gh_split[1] %}
15-
15+
1616
<div id="header-gh-btns">
1717
{% if page.gh-badge.size > 0 %}
1818
{% for badge in page.gh-badge %}
@@ -22,15 +22,15 @@
2222
{% when 'watch'%}
2323
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&repo={{ gh_repo }}&type=watch&v=2&count=true" frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
2424
{% when 'fork'%}
25-
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&repo={{ gh_repo }}&type=fork&count=true" frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
25+
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&repo={{ gh_repo }}&type=fork&count=true" frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
2626
{% when 'follow'%}
2727
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&type=follow&count=true" frameborder="0" scrolling="0" width="220px" height="20px"></iframe>
2828
{% endcase %}
2929
{% endfor %}
3030
{% endif %}
3131
</div>
3232
{% endif %}
33-
33+
3434
<article role="main" class="blog-post">
3535
{{ content }}
3636
</article>
@@ -40,7 +40,7 @@
4040
Tags:
4141
{% if site.link-tags %}
4242
{% for tag in page.tags %}
43-
<a href="/tag/{{ tag }}">{{ tag }}</a>
43+
<a href="{{ site.baseurl }}/tags#{{- tag -}}">{{- tag -}}</a>
4444
{% endfor %}
4545
{% else %}
4646
{{ page.tags | join: ", " }}
@@ -72,4 +72,4 @@
7272
{% endif %}
7373
</div>
7474
</div>
75-
</div>
75+
</div>

_layouts/tag_index.html

-41
This file was deleted.

_plugins/_tag_gen.rb

-33
This file was deleted.

css/main.css

+6
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,9 @@ td.gutter {
743743
.navbar-default button.navbar-toggle[aria-expanded="true"] {
744744
background-color: rgba(0, 0, 0, 0.2);
745745
}
746+
747+
/* fix btn spacing in tag index */
748+
749+
.tag-btn {
750+
margin: 5px;
751+
}

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h3 class="post-subtitle">
4444
Tags:
4545
{% if site.link-tags %}
4646
{% for tag in post.tags %}
47-
<a href="{{ site.baseurl }}/tag/{{ tag }}">{{ tag }}</a>
47+
<a href="{{ site.baseurl }}/tags#{{- tag -}}">{{- tag -}}</a>
4848
{% endfor %}
4949
{% else %}
5050
{{ post.tags | join: ", " }}

tags.html

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
layout: page
3+
title: 'Tag Index'
4+
---
5+
6+
{%- capture site_tags -%}
7+
{%- for tag in site.tags -%}
8+
{{- tag | first -}}{%- unless forloop.last -%},{%- endunless -%}
9+
{%- endfor -%}
10+
{%- endcapture -%}
11+
{%- assign tags_list = site_tags | split:',' | sort -%}
12+
13+
{%- for tag in tags_list -%}
14+
<a href="#{{- tag -}}" class="btn btn-primary tag-btn"><i class="fa fa-tag" aria-hidden="true"></i>&nbsp;{{- tag -}}</a>
15+
{%- endfor -%}
16+
17+
{%- for tag in tags_list -%}
18+
<h3 id="{{- tag -}}"><i class="fa fa-tag" aria-hidden="true"></i>&nbsp;{{- tag -}}</h3>
19+
<ul class="post-list">
20+
{%- for post in site.tags[tag] -%}
21+
<li>
22+
<i class="fa fa-calendar-check-o" aria-hidden="true"></i>&nbsp;
23+
<span class="entry-date">
24+
<time datetime="{{- post.date | date_to_xmlschema -}}">{{- post.date | date: "%B %d, %Y" -}}</time>
25+
</span>
26+
<i class="fa fa-newspaper-o" aria-hidden="true"></i>&nbsp;
27+
<a href="{{- site.url -}}{{- post.url -}}">{{- post.title -}}</a>
28+
</li>
29+
{%- endfor -%}
30+
</ul>
31+
{%- endfor -%}

0 commit comments

Comments
 (0)