How to create a blog using GitHub Pages and Jekyll in 1 day
September 02, 2018 8 minutes read Join the discussion Blogging HowtoWhat should my first post be about if not about the genesis of this blog?
GitHub Pages and Jekyll were the choice to form the foundation of this website, but there were a lot of bits and pieces that polished it.
Did this choice worth it? Completely! Any engineer would understand the choice. We love the challenges, the puzzles, the ups and downs when building something. GitHub Pages and Jekyll give you the chance to manually configure your blog as you like and get dirty when adding the features that you need. Oh, we love getting dirty. 😉
Set the blog foundation
- 1. Start your blog using GitHub Pages
- Here you will find how to link your GitHub repository to your new public website.
- 2. Choose a Jekyll theme
- This blog uses the Lanyon that gives you a basic blog out of the box.
Make your blog ready to meet the world
Even if you can start writing posts, your blog is not as shiny as you imagined it. But it can be…
1. Configure your contact list
If you started writing a blog, for sure you worked in a lot of other interesting projects. Use your blog to share your contributions to the community.
The sidebar can a very good place to gather your contact list. You can use a minimalistic way to hint them, by using Font Awesome.
Just load the stylesheet in your head.html file:
and start using them in your sidebar.html file:
2. Add reading time
You could help your readers by listing the estimated reading time of a blog post. They will use it to decide if that’s the time to read the post or if they should postpone it for later.
Here you can find a very good example of how to compute the reading time based on the post content length.
3. Create drafts for your posts before publishing them
Don’t hesitate versioning your post drafts. You can safely do this by putting your draft files in a _drafts directory.
GitHub Pages will know how to deal with the _drafts content and not publish it.
Locally you can always preview your drafts by running the jekyll
command with the --drafts
flag: jekyll server --watch --drafts
When your post is ready, just move it in the _posts directory.
4. Add post excerpts in the Home page
By default, the Lanyon theme shows all posts (with their entire content) in your blog Home page. If you want to change this behavior and display only a post teaser instead, you need to configure the so called post excerpts.
For this, you’ll have to choose an excerpt separator and specify it in the _config.yaml file.
To display the post excerpts instead of the contents, you’ll need to change the index.html file accordingly.
Then, when writing your post you will manually use the excerpt separator in the place where you want your post teaser to stop.
5. Change the post date format
In case you don’t like the default date format for your posts (i.e. date_to_string, e.g. 03 May 2013), you can easily change it by configuring your preferred format.
Check this post for more examples.
6. Monitor your website traffic with Google Analytics
Google Analytics can prove to be a very good tool to better understand your readers. Apart from tracking the views count of your blog, you can use Google Analytics to see the pages that are visualised the most, when are blog posts most visited, or how much time the readers spend on your blog.
Based on these details, you can decide what to write next.
You can follow this blog post to configure Google Analytics for your new website.
7. Enable Disqus comments
You will want to keep in touch with your readers, receive suggestions and offer support when there are any questions. Enabling post comments can help you in this regard.
Disqus is a good tool for this. Create an account and follow their instructions to enable comments for your blog posts.
Add the new Disqus information in the config.yaml file:
Load Disqus comments using this comments.html file:
Include comments in the posts layout:
To display the number of comments for your posts, load the following script in your default.html file:
Display the number of comments in your post.html file:
8. Add tags
You can annotate your posts with one or more tags and allow this way grouping them by category. This way, if your readers are interested in a certain subject, they can easily view all posts related to it.
To have this feature, start by adding tags to each one of your posts. For example, like this:
For every post, dynamically display the tags in the posts.html layout:
Add a link to the new Tags page in the sidebar.html file:
Create a new tags.md file and reference the categories layout:
Create the corresponding categories.html layout file:
9. Enjoy your new blog 🍺
PS: You can always have a look at my GitHub repository to see how I configured this blog.