Customising the default Jekyll theme (with minimal fuss)
• Greg Matthew Crossley
You can use Jekylls "inheritance" feature to avoid messing around with the Minima theme’s files.
Jeykll is supposed to be simple, right? This site uses it, and I chose it because I wanted a static site that I could add content to with minimal friction. I think I chose well, but one thing kinda bothered me - why isn’t it more obvious how to make minor style changes?
Because Jekyll supports inheritance with its layouts, you can leave the Minima theme files entirely intact (and tucked away in the gem they are now in, since version 3.2). The trick is to inherit and extend Minima’s three default layouts, which are home, page and post. Here’s how:
Add a layouts folder and some custom layouts
Add a folder called _layouts to the base of your project folder. If you’re running Jekyll prior to version 3.2, this may already exist. Then add three layout files to this new folder: home_with_custom_styling.html, page_with_custom_styling.html and post_with_custom_styling.html. Here’s one of mine:
Pretty simple: this new layout just inherits from the default page layout, but uses Jekyll’s include functionality to add some additional HTML to the top of the page.
Add an includes folder and an HTML file with custom styling
Now create an _includes folder in the base of your project folder, if it doesn’t exist, and create a file called custom_styling.html. In this file, we’ll use <style> and <link> HTML elements to append CSS and load custom fonts over top of the default Minima theme. This site’s custom_styling.html looks like this:
Use your new layouts in any new posts or pages
Don’t forget to use your new layouts when you make a new post or page! For example, the file for this post starts with these lines:
Presto, chango, you’ve got a lightly restyled site, while maintaining the integrity of the default Minima theme. No fuss neccesary!