Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining Variable Configuration in _config.yml in jekyll powered website

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 ?

like image 333
Sachin Avatar asked Dec 14 '25 02:12

Sachin


1 Answers

No you cannot use variables in a _config file.

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

like image 101
David Jacquel Avatar answered Dec 16 '25 18:12

David Jacquel