Search code examples
jekyll

How can I create a Jekyll variable from another in _config.yml?


I would like to create a variable for the image path in _config.yml. I have defined baseurl and want a new one called urlimg: 'baseurl+'images/' Is that syntax correct?

urlimg: baseurl.'/images/'

Solution

  • My advice would be to create two variables in your config.yml, like this:

    url: https://www.example.com/
    baseurl: site/
    imageurl: images/
    

    And use them in your template, like this:

    {{ imageurl | prepend: site.baseurl | prepend: site.url }}