【发布时间】:2015-02-04 18:57:45
【问题描述】:
我正在使用 Jekyll 和 Liquid 在 GitHub 页面上生成一个静态网站。我从 templated.co (this one, specifically) 找到了一个用于页面布局的模板。
我让 Jekyll 正确地提供了内容,但我想通过在 CSS 中使用 Liquid,在每个页面上使用不同的背景图片(代替现在的默认图片)。我让 Jekyll/Liquid 通过在 style.css 中添加一个空的前端部分来识别 CSS,但是我无法获得以下行来允许我根据需要调整背景图像:
background: url(../images/{% if page.bgimage %}{{ page.bgimage }}{% else %}{{ site.bgimage }}{% endif %}) no-repeat bottom center;
我可以通过将bgimage: whatever.jpg 放入_config.yml 来更改所有页面的背景图像,但不能在页面的前面添加类似bgimage: otherimage.jpg 的行以使其使用otherimage.jpg 而不是whatever.jpg 作为背景图片。
我想做的事情是否可行,或者我只是遇到了一些语法问题?
提前感谢您的帮助。
【问题讨论】:
标签: css jekyll liquid github-pages