liquid - Is there a way to check whether a jekyll site is being served locally? -
i'd add following line head.html solely when running jekyll serve locally:
<script src="http://127.0.0.1:35729/livereload.js?snipver=1"></script> i'm thinking of using simple liquid check if possible.
alternative solution (for example, if you're hosting jekyll site on own server , not on github pages):
you can set value in config file _config.yml this:
environment: prod then, can have config file overrides same value, i'll call config_dev.yml:
environment: dev when call jekyll build, use value prod real config file.
but when build site on local machine testing, pass both config files in order:
jekyll build --config _config.yml,_config_dev.yml the value second config file override value first config file, environment set dev.
and can same described in david's answer:
{% if site.environment == "dev" %} <script src="http://127.0.0.1:35729/livereload.js?snipver=1"></script> {% endif %} you can see example in the source code of blog:
_config.yml_config_dev.yml- windows batch file run
jekyll buildin "dev" mode - layout file, i'm using
environmentvariable to:- disable google analytics in dev mode
- change urls i'm loading js , css files
(dev mode: local server / prod mode: cdns)
Comments
Post a Comment