How to detemine if jekyll running locally or in production site?

前端 未结 4 1765
谎友^
谎友^ 2021-02-13 03:25

There is a config param in jekyll called production_url. I can\'t find any information on how to use it.

Ideally i would like to be able to generate permalinks with loc

4条回答
  •  自闭症患者
    2021-02-13 04:07

    I don't see the variable production_url in the current release (v1.4.1), so this may be a dated question--but I was just looking for this answer myself. There is a baseurl property that can be set with a flag and so to change the path to your files, but it only adjusts the relative path.

    jekyll serve --baseurl '/blog'
    

    What you can do is to use the -config option to specify a configuration file for development.

    Jekyll Documentation

    Your production configuration variables are defined in _config.yml. One option is to create a separate configuration file for development.

    --config _config-dev.yml
    

    You can also (as I do) override variables defined in a second configuration file.

    --config _config.yml,_config-dev.yml
    

    If you use the liquid templates for site links like this:

    
    

    then you can override the base_url property during local devlopment

    base_url:           http://localhost:4000
    

    and run jekyll in "Development"

    jekyll serve -w --config _config.yml,_config-dev.yml
    

提交回复
热议问题