3

There are multiple sets of configuration which you may want to execute when you are running the site locally while when your site is running on server (say Github).

I have defined similar set of configuration in my _config.yml file like this

title: Requestly
locale: en_US
description: Chrome Extension to modify HTTP(s) Requests
logo: site-logo.png
search: true
env: dev

config:
  dev:
    url: http://localhost:4000
  prod:
    url: http://requestly.github.io/blog

url: site.config[site.env].url // Does not work

I have used {{ site.url }} everywhere else in my templates, layouts and posts.

How can I define site.url in my _config.yml file whose value depends upon the config and env defined in the same file.

PS: I know one of the ways is to change {{ site.url }} to {{ site.config[site.env].url }} in all the files. That should probably work.

I just want to know how to use variables in _config.yml. Is that even possible ?

Anthon
  • 69,918
  • 32
  • 186
  • 246
Sachin Jain
  • 21,353
  • 33
  • 103
  • 168

2 Answers2

2

No you cannot use variables in a _config file.

You can find more informations here : Change site.url to localhost during jekyll local development

David Jacquel
  • 51,670
  • 6
  • 121
  • 147
0

Yes you can with Jekyll 3.8.0 or later version now. Please give that a try

Giang Phạm
  • 59
  • 1
  • 4