Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jekyll

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 local url when it is being run with serve param and with production url when run with build param.

How could I do that?

like image 324
husayt Avatar asked May 21 '13 21:05

husayt


1 Answers

When you build your Jekyll website, it’s possible to specify the environment it’s using for the build with the JEKYLL_ENV environment variable:

$ JEKYLL_ENV=production jekyll build

If you don’t set JEKYLL_ENV explicitly, it defaults to development.

{% if jekyll.environment == "production" %}
    // Production environment.
{% endif %}

Github Pages automatically sets the environment to production.

like image 127
Tommsy64 Avatar answered Sep 21 '22 02:09

Tommsy64