Skip to content

Instantly share code, notes, and snippets.

@opattison
Created August 28, 2013 01:11
Show Gist options
  • Save opattison/6361011 to your computer and use it in GitHub Desktop.
Save opattison/6361011 to your computer and use it in GitHub Desktop.
How to use YAML front matter variables in a CSS file to define colors using variables in Jekyll, using Liquid tags. This example uses HSL colors with hex fallback colors. The goal here is to create standardized CSS with a color palette that can easily be extended to a whole file and maintained easily with only a few variables. The same thing cou…
---
white:
hsl: 'hsla(138, 10%, 98%, 1)'
hex: '#f9fafa'
black:
hsl: 'hsla(138, 16%, 10%, 1)'
hex: '#151e18'
green:
hsl: 'hsla(138, 39%, 54%, 1)'
hex: '#5cb777'
---
html {
background: {{ page.white.hex }};
background: {{ page.white.hsl }};
color: {{ page.black.hex }};
color: {{ page.black.hsl }};
}
a {
color: {{ page.green.hex }}
color: {{ page.green.hsl }}
}
@gibatronic
Copy link

wonderful that nowadays we have custom properties in CSS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment