Welcome to this blog’s first post, and how it started, by running jekyll inside a docker container.
It’s actually very easy to start your own blog with Jekyll using docker, but for first time users, sometimes things get complicated.
So let’s easy things up. I’ve created a base blog, with a template already in place that is based upon the same template used for this blog with some modifications to CSS and templating system to better serve the purpose of this blog.
So let’s start by Cloning this project
Clone with ssh (preferred mode)
1 git clone firstname.lastname@example.org:Ilhicas/jekyll-docker-base.git
Or use https
1 git clone https://github.com/Ilhicas/jekyll-docker-base.git
Now change directory to the folder jekyll-docker-base created after cloning
And just run:
1 docker-compose up -d
You can now check what’s going on after the image layer (from oficial jekyll docker hub repo) has downloaded and its up.
1 docker-compose logs -f
It should give an output similar to
1 2 3 4 5 6 Attaching to jekyldockerbase_blog_1 blog_1 | Fetching gem metadata from https://rubygems.org/............. blog_1 | Fetching public_suffix 3.0.2 blog_1 | Installing public_suffix 3.0.2 blog_1 | Fetching addressable 2.5.2 blog_1 | Installing addressable 2.5.2
And can be stuck for a while in
Attaching to jekyldockerbase_blog_1
And when done it should ouptut
1 2 3 4 5 6 7 8 blog_1 | Source: /srv/jekyll blog_1 | Destination: /srv/jekyll/_site blog_1 | Incremental build: disabled. Enable with --incremental blog_1 | Generating... blog_1 | done in 0.59 seconds. blog_1 | Auto-regeneration: enabled for '/srv/jekyll' blog_1 | Server address: http://0.0.0.0:4000/ blog_1 | Server running... press ctrl-c to stop.
When satisfied press
ctrl-c - this won’t actually stop as we are only running log output of docker container
Ok so now let’s navigate to http://localhost:4000
We should have something similar to this:
Writing your first post
For those who have never seen
Jekyll before, it makes use of markdown and all posts (for simplicity here reside under _posts)
And must have the following structure
This is the minimum, if you wish to know more about date etc, go to jekyll posts
To get you started it comes with a first post that you should edit to try it out.
Don’t forget you must always use frontmatter.
For the first post this is the first part of the .md file, and uses yaml
1 2 3 4 5 --- layout: post title: This is this blogs first post tags: [jekyll, docker] ---
If you wish to mess up with the css , Im using the amplify theme, so the css file to edit is under _includes/styles.scss
You can always change your posts templates under the
|And your header||footer||etc under |
Making it your own
In order to make it your own, don’t forget to edit the ` _config.yml` so that you can change your settings, like google analytics by just setting the appropriate UID
And change the
about.md to change the page containing your bio.
Do I need to restart docker for every change?
No, all changes made to assets and content, are always re-evaluated on the fly.
However changes made to
_config.yml only get evaluated on startup.
So if you made any changes to
_config.yml just reload the container. How?
1 docker-compose restart
And your changes should be visible.
Are you done with testing?
1 docker-compose down
And that’s it.
And that’s it for now.
Will post and link soon a Post telling you how to deploy easily, and generate SSL certificates soon, with the same simplicity as in this Post.
Thanks for reading.