Skip to main content
  1. Posts/

Customizing the Jekyll Theme

Chris Ayers
Author
Chris Ayers
I am a father, nerd, gamer, and speaker.

I haven’t done a lot with jekyll in the past, but I’m a big fan of Markdown everything. For me that usually means I’m taking notes in Markdown Obsidian, doing diagrams in mermaid in Azure DevOps or https://mermaid.live/. I’ve even started turning my talk slides into Markdown with a tool called MARP.

Understanding when I use standard Markdown or some sort of templating language (jekyll uses Liquid) has been fun. I’ll do something in HTML or Markdown, then find out that Jekyll or my theme already has helpers to render that (like gists, videos, and figures). Sometimes rendering more advanced things takes a little tweaking of Jekyll and the theme.

Lets take Mermaid for example. If I want to render mermaid, it won’t work out of the box with jekyll or my theme. I need to tweak things and initialize things manually. If I want to render a graph, this won’t work out of the box.

    '''mermaid
    graph TD;
        A-->B;
        A-->C;
        B-->D;
        C-->D;
    '''

So to make it work, I had to override the base theme. To start, I looked at the themes layouts. They live in the _layout folder of the theme here. These are the base structure of a page and most reference either Archive or Default.

Fortunately Archive also refers to Default so I can focus my changes there if I want to override it.

Looking at this file, there are a few includes defined. One of which is the footer/custom.html and one is scripts.html. I looked through the scripts.html and it has a lot of logic I’d prefer not to duplicate. I’m already using the header-custom file to define some css/scripts. I’ve found Mermaid needs its init to run in the body, so i’ll probably want to leverage the footer/custom.html for this. It’s an empty file in the theme, making it any easy choice to override.

I created a footer folder in my local project _includes and a custom.html file. I added some simple logic to only add the mermaid logic if I added a mermaid:true flag at the top of the page.

So lets set that!

At this point, everything should work and embedded mermaid in my Markdown posts renders properly!

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

I’ve done a few other minor customizations so far. Like adding some custom CSS and some JavaScript for app insights. Both of those involved a similar process of adding head/custom.html and assets/css/custom.css.

I used a few different sources to get things to work for me. Please check those out as well to see if they can help you:

Thanks for following along on this journey. I hope this helps those starting their Jekyll journey or hosting on GitHub Pages.

Related

Migrating from WordPress to GitHub Pages

I’ve been hosting on WordPress for a while. I wanted something that worked pretty well and was easy to work with. I picked a decent theme, added some plugins, pointed my domains and was up and running. I would work on blogs in Markdown, and then paste the txt into a Markdown. I could upload a few images and move them around in a wysiwyg. Lately, I’ve been doing a lot more in Markdown. All my conference talks were in PowerPoint but I’ve started switching over to Markdown slides using MARP. I should probably do a post on MARP sometime (I did :-) ). I wanted to reduce my overhead of WordPress Hosting and get back into more direct styling and coding of my theme. I decided to switch my hosting to Jekyll on GitHub Pages.

Validating .NET Configuration

·703 words·4 mins
This blog was posted as part of the C# Advent Calendar 2022. I really want to thank Matthew D. Groves and Calvin Allen for helping set this up! Look for #csadvent on Twitter! Make sure to check out everyone else’s work when you’re done here One of the great things about the configuration system in .NET is the type safety, dependency injection, and model binding. Something we can take advantage of is to validate our configuration on startup and fail if it doesn’t pass validation. Having that fast failure is awesome when working with containers and applications that have liveness and readiness probes.

Presenting Best Practices - Part 1

·940 words·5 mins
Presenting and speaking are skills that require practice to hone. I was a consultant for many years presenting to clients and customers of all levels and sizes. In addition, I started speaking and presenting at meetups, user groups, and conferences. Over the years, I practiced, I read, and I gave a lot of presentations. I’d like to share some of the learnings and best practices I’ve found in that time. I plan multiple posts, starting with Preparation. I’ll have more on slide design, and presentation tips.

Shared Focus - Using The First Way with DevOps

·366 words·2 mins
A common issue I see when discussing DevOps with teams or organizations is the presence of Organizational Silos. Organizational Silos are made up of all types of people. Sometimes its a job type, like developers, qa, or infrastructure. Sometimes its a department, like accounting, or hr. Whatever the composition of these silos, they usually impact organizational performance and the ability to deliver value to end users. This happens over time, with members of the silo identifying with each other, viewing those not in the silos as outsiders. Depending on the business, the silos can lose trust in the business overall and tighten ranks around their silo. The silos can turn into walled fortresses. When the silos get in the way, the silos are more focused on their own success than the success of the organization.

Some Tools to Help Present Git

·416 words·2 mins
I’m presenting soon on Advanced Git. I feel a lot of Developers and DevOps engineers know enough git to the job, but sometimes that’s it. I want to help people be more comfortable with the git command-line, and help alleviate some fear or hesitation in dealing with git edge cases. While researching things, I came across a few neat tools I’m using to help describe things.