Skip to content

Commit

Permalink
Replaces tag index plugin with native jekyll features (daattali#307)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
OCram85 authored and daattali committed Jan 19, 2018
1 parent 9470998 commit 70f4850
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 88 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

## Prerequisites

- 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`.
- 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`.
- 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/).

## Build your website in 3 steps

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

![Installation steps](img/install-steps.gif)
Expand Down Expand Up @@ -142,11 +142,11 @@ image | If you want to add a personalized image to your blog post that wil
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.
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).
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.
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)
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)
js | List of local JavaScript files to include in the page (eg. `/js/mypage.js`)
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="`
css | List of local CSS files to include in the page
ext-css | List of external CSS files to include in the page. External CSS files using SRI (see `ext-js` parameter) are also supported.
ext-css | List of external CSS files to include in the page. External CSS files using SRI (see `ext-js` parameter) are also supported.
googlefonts | List of Google fonts to include in the page (eg. `["Monoton", "Lobster"]`)
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.
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.
Expand Down Expand Up @@ -207,7 +207,7 @@ Want your website featured here? [Contact me](http://deanattali.com/aboutme#cont

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:

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

2. Clone your repository locally.

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

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!
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.
## FAQ
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.
Expand Down
3 changes: 2 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ navbar-links:
- Learn markdown: "http://www.markdowntutorial.com/"
- GitHub Pages: "https://pages.github.com/"
Author's home: "http://deanattali.com"
Tags: "tags"

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

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

# Exclude these files from production site
exclude:
Expand Down
10 changes: 5 additions & 5 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% assign gh_split = page.gh-repo | split:'/' %}
{% assign gh_user = gh_split[0] %}
{% assign gh_repo = gh_split[1] %}

<div id="header-gh-btns">
{% if page.gh-badge.size > 0 %}
{% for badge in page.gh-badge %}
Expand All @@ -22,15 +22,15 @@
{% when 'watch'%}
<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>
{% when 'fork'%}
<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>
<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>
{% when 'follow'%}
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&type=follow&count=true" frameborder="0" scrolling="0" width="220px" height="20px"></iframe>
{% endcase %}
{% endfor %}
{% endif %}
</div>
{% endif %}

<article role="main" class="blog-post">
{{ content }}
</article>
Expand All @@ -40,7 +40,7 @@
Tags:
{% if site.link-tags %}
{% for tag in page.tags %}
<a href="/tag/{{ tag }}">{{ tag }}</a>
<a href="{{ site.baseurl }}/tags#{{- tag -}}">{{- tag -}}</a>
{% endfor %}
{% else %}
{{ page.tags | join: ", " }}
Expand Down Expand Up @@ -72,4 +72,4 @@
{% endif %}
</div>
</div>
</div>
</div>
41 changes: 0 additions & 41 deletions _layouts/tag_index.html

This file was deleted.

33 changes: 0 additions & 33 deletions _plugins/_tag_gen.rb

This file was deleted.

6 changes: 6 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -743,3 +743,9 @@ td.gutter {
.navbar-default button.navbar-toggle[aria-expanded="true"] {
background-color: rgba(0, 0, 0, 0.2);
}

/* fix btn spacing in tag index */

.tag-btn {
margin: 5px;
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h3 class="post-subtitle">
Tags:
{% if site.link-tags %}
{% for tag in post.tags %}
<a href="{{ site.baseurl }}/tag/{{ tag }}">{{ tag }}</a>
<a href="{{ site.baseurl }}/tags#{{- tag -}}">{{- tag -}}</a>
{% endfor %}
{% else %}
{{ post.tags | join: ", " }}
Expand Down
31 changes: 31 additions & 0 deletions tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
layout: page
title: 'Tag Index'
---

{%- capture site_tags -%}
{%- for tag in site.tags -%}
{{- tag | first -}}{%- unless forloop.last -%},{%- endunless -%}
{%- endfor -%}
{%- endcapture -%}
{%- assign tags_list = site_tags | split:',' | sort -%}

{%- for tag in tags_list -%}
<a href="#{{- tag -}}" class="btn btn-primary tag-btn"><i class="fa fa-tag" aria-hidden="true"></i>&nbsp;{{- tag -}}</a>
{%- endfor -%}

{%- for tag in tags_list -%}
<h3 id="{{- tag -}}"><i class="fa fa-tag" aria-hidden="true"></i>&nbsp;{{- tag -}}</h3>
<ul class="post-list">
{%- for post in site.tags[tag] -%}
<li>
<i class="fa fa-calendar-check-o" aria-hidden="true"></i>&nbsp;
<span class="entry-date">
<time datetime="{{- post.date | date_to_xmlschema -}}">{{- post.date | date: "%B %d, %Y" -}}</time>
</span>
<i class="fa fa-newspaper-o" aria-hidden="true"></i>&nbsp;
<a href="{{- site.url -}}{{- post.url -}}">{{- post.title -}}</a>
</li>
{%- endfor -%}
</ul>
{%- endfor -%}

0 comments on commit 70f4850

Please sign in to comment.