Running Jekyll + Github Pages on a Google domain
09 Dec 2019I just setup a new Jekyll site and hosted it using Github Pages and a Google domain. I’m happy with the results, so I wanted to explain my process and shed light on a few pitfalls.
Language and Site Generator : Ruby and Jekyll
I seldom use Ruby, but some of the most common site generators are written in Ruby, so I explored Jekyll and Hugo. I chose Jekyll because I found more examples and more documentation. Jekyll installation would require RubyGems (gem
) GCC and Make. I had a jekyll-served site locally in 3 hours, and hosted it on the internet in a few days.
Template Language: Liquid
Jekyll uses the Liquid template language. Liquid supports content in Markdown and/or HTML – I find Markdown easier to read and write. Liquid supports template-style features like objects ( {{ page.title }}
), tags ({% if page.show_sidebar %}
), and filters ({{ "welcome" | uppercase }}
)
With Liquid you can easily refere a page’s variables, or a site’s collections.
Content: Pages, Post and Front Matter
Pages are generic, like any webpage. Posts are more specific and support more specfic metadata like dates, categories and tags.
Themes
I created a set of themes based on Hyde
Front Matter
I found “Front Matter” to be especially useful; Front Matter lets you attach properties to your content.
- Front Matter was easy compared to a Python Flask server (where I’d need a database and more server-side programming – too much work)
- Front Matter can be accessed in Liquid, through objects and tags (like
for
-loops)
Collections
For defining new “classes” of content, you can create a collection. In my case I wanted to highlight many of my “featured works”, so I created a collection called featured_works
.
Troubleshooting
- remote-theme; had to add
repository:
info to the_config.yml
to satisfyjekyll-github-metadata
plugin as described here - errors when I also installed gh-pages; tried to locate a theme despite using a
remote_theme
- remote theme folder names; must be named
assets
, notpublic
; so I forked the theme (hyde) with this change
Helpful links:
- on Google domain to point at github page (Although
CNAME
file should just have one item in it?)Firstly, if you used to be using
A
records then you may need to remove and re-add your custom subdomain from your repository’s settings. This will generate you a certificate for your domain. To do this, firstly go to your repository settings…- More info here
- correct IP address to mention in
CNAME
file and here and here; and finally here
Running
I use the command bundle exec jekyll serve
If I tried just jekyll serve
, I might get this error:
You have already activated i18n 1.7.0, but yourGemfile requires i18n 0.9.5. Prepending
bundle exec
to your command may solvethis. (Gem::LoadError)