Notes on Jekyll
Well, I have made some changes to the base Jekyll installation that I thought I should share.
Pagination
Pagination for Jekyll, while built in, isn’t configured with the default layout. To add this, you need to make a few changes.
First, add the paginate
tag to your _config.yml
with how many blog posts you want to display per page.
Then, change your index.html
where it says {% for post in site.posts %}
to {% for post in paginator.posts %}
. This changes it to use the paginator’s list of posts instead of the sites global list.
Finally, you need to add the Previous and Next buttons to your index.html
with this snippet:
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
{% endif %}
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path }}" class="next">Next</a>
{% endif %}
</div>
Images
The Jekyll documentation made this slightly confusing when its really really not.
To host static files, such as images or your own CSS, simply create a folder in the root of your site, and it will be there in the built site. (As long as it doesn’t start with an underscore)
Github Pages
Github Pages are surprisingly easy to get setup and run a personal site or blog on.
Repo Creation
Simply create a repository called {YOUR_GIHUB_USERNAME}.github.io
and commit either static HTML, or your Jekyll sites buildable files.
Custom Domains
This is a bit more complex to follow in the documentation for Github Pages. But its not too hard in the end, however I’m not sure on its efficiency and this may break things on your domain, I make no claims to know tonnes about domains, just how to use them in a hackish manner.
For my Github Pages setup, I am using both ry167.github.io
and blog.ry167.com
. ry167.github.io
is setup automatically with the creation of the repository.
To add another domain however, you have to create a CNAME
or A
DNS record at your domain registrar.
CNAME
If you are creating a subdomain of your existing domain, like I am doing, you add a CNAME
record and point it to your {USERNAME}.github.io
URL.
Then create a file in the repository called CNAME
(case sensitive) and add the subdomain you just created to it, such as blog.ry167.com
A
If you are wanting to send the root of a domain, not a subdomain to your Github Pages, then you need to create 2 A
records for the root of your domain and point them to 192.30.252.153
and 192.30.252.154
.
Then, similar to a CNAME
record, you need to create a CNAME
file in your repository and have the contents as the domain you just pointed to it, such as blog.ry167.com
Then wait for them to resolve and they should work, as well as your original .github.io
URL.
Permalinks
I prefer my permalinks differently to the standard Jekyll style of /:categories/:year/:month/:date/:title.html
, but thankfully you can change this in _config.yml
by adding:
You can customize it however you want following the documentation and different parameters on this page
Sitemap
After trying to submit this site to Google Webmaster, I realized I would need to generate a site map, which thankfully Github Pages recommends a Gem for, called jekyll-sitemap.
To set it up, all you need to do is add the following to _config.yml
:
This will generate a site map located at /sitemap.xml
for every page and post.
You can remove pages by adding sitemap: false
to their YAML Frontmatter, like I have done with the Google Webmaster verification file
Closing
Well, I hope this helps someone one day, and I may update this post if any further changes I make to Jekyll are not worthy of their own posts.