Jekyll define fonts in config.yml

我的未来我决定 提交于 2019-12-12 18:18:15

问题


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;
}

回答1:


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.




回答2:


Why not simply declare these variables in your sass file ?



来源:https://stackoverflow.com/questions/38955342/jekyll-define-fonts-in-config-yml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!