blogging with Jekyll
In this post, we will take a brief look at how to work with Jekyll. We assume that Jekyll has been successfully installed and is working fine.
Content
Jekyll Init
Setting up a new Jekyll site (on GitHub).
- create a new repository on Github with the following name:
<GitHub User>.github.io
- clone that repository to a local dev folder (
myJekyllRepo
in this example) - create a new Jekyll site in the same local dev folder
- in the dev folder, create a
_drafts
folder - add all files to git in an initial commit
$ git clone https://github.com/<GitHub User>/<GitHub User>.github.io.git myJekyllRepo
$ jekyll new myJekyllRepo
$ cd myJekyllRepo
$ mkdir _drafts
$ git add --all
$ git commit -m "initial commit for myJekyllRepo"
$ git push
Customizing the new Jekyll site.
- to come
- to come
- …
Jekyll Flow
From a rough idea to a published blog post.
- Think of a title (e.g., Jekyll Flow) for your new post.
-
In your
_drafts
folder, create a new empty<title>.md
file (e.g.,jekyll-flow.md
)$ touch title.md
-
Add minimal Front Matter
--- layout: <document type> title: <title> date: <date> categories: <categories> tags: <tags> ---
where
<document type>
ispost
orpage
(or others, depending on the used layout)<title>
is your title<date>
is the date the post should be filed under (if omitted, date will be taken from post name, see step 7. below)<categories>
is one or more (space seperated) categories the post should be filed under (note: the categories are hierarchical.cat1 cat2
means the post will be filed under/cat1/cat2/...
)-
<tags>
is one or more tags that should be associated with the post -
your new file could look similar to this
--- layout: post title: blogging with Jekyll date: 2015-10-26 categories: Jekyll Code --- This is my new blog post...
-
Start local Jekyll Server with
--draft
option.$ bundle exec jekyll serve --draft
-
Open newly created post in browser at
127.0.0.1:4000
. -
Edit-Review Cycle a) edit the contents of your post b) save post (it will automatically be regenerated by Jekyll) c) hit F5 on browser to refresh page d) review post e) while not finished and satisfied, continue with step 6.a)
-
Once satisfied and ready to publish, move your post from the
_drafts
to the_posts
folder, and prepend the date to the filename (inYYYY-MM-DD-title.md
format).$ mv _drafts/jekyll-flow.md _posts/2015-10-26-jekyll-flow.md
-
Start local Jekyll Server without
--draft
option, and verify that the post is generated and filed as expected.$ bundle exec jekyll serve
-
Commit and push your new post to your remote Github repository
$ git add _posts/ $ git commit -m "added a new post" $ git push
- Give Github some time to run Jekyll for you
- enjoy your new blog post @
http:\\<GitHub User>.github.io
Hope this helps somehow. :)
Best, Thomas
N.B. The best wishes to my father. It’s his birthday today! :)