mqvlm mqvlm - 3 months ago 29
YAML Question

Jekyll define fonts in config.yml

I'm trying to define font variables in my jekyll template's _config.yml so that I can use liquid in my css and change all type styles directy from config. Somehow it's not rendering, is this even possible?

This is what I have in my _config:

fonts:

primary: Roboto Slab

secondary: Helvetica


And css:

body {
font-family: '{{ site.fonts.primary }}',{{ site.fonts.secondary }},Arial,sans-serif;
}

Answer

You have to provide YAML front matter in order for Jekyll to process Liquid tags in the css file:

---
---
body {
  font-family: '{{ site.fonts.primary }}',{{ site.fonts.secondary }},Arial,sans-serif;
}

The --- lines are the start and end of YAML front matter. You do not need to define anything in it.