This content originally appeared on @mdo and was authored by Mark Otto
Jekyll is a blog aware static-site generator. It’s great for building simple pages like Code Guide or blogs like this one. Lately, I’ve been a big fan of Jekyll’s include functionality.
Now, most folks use _includes
for standard partials like a site’s header or footer. Lately though, I’ve been using them to easily include CSS dependencies for fewer page requests.
Say you have three CSS files to include in your Jekyll project. Normally you’d do something like this:
With Jekyll, you can turn that into one file during site generation with includes and YAML front-matter. Here’s an example Gist.
The front-matter tells Jekyll to treat this page as a buildable file rather than simply another asset to copy to the generated _site
folder. With that in place, add any _includes
you like, and run jekyll serve
.
Enjoy!
This content originally appeared on @mdo and was authored by Mark Otto
Mark Otto | Sciencx (2014-02-28T00:00:00+00:00) Including CSS in Jekyll. Retrieved from https://www.scien.cx/2014/02/28/including-css-in-jekyll/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.