Jekyll Constant Values

Jekyll Constant Values plugin allows you to render constant values in the .html files of your Jekyll project. This way, if you have words that you repeat a lot or words that are susceptible to changes (like the number of workers in your company), this plugin helps you to only have to modify the value in a single file.

1. Installation

  1. Add the following to your site's Gemfile:
gem 'jekyll_constant_values', group: :jekyll_plugins
  1. Run bundle install in your command line:
$ bundle install
  1. Create a new YAML file called constants.yml under your _data/ folder. If you prefer, you can customize the name of the file (must be also under _data/) and put the name of your custom file without the extension in your _config.yml file this way:
constants: your-custom-name

2. Usage

  1. Fill your constants YAML file with the content you need:
company_name: Group Hirthe-Ritchie
contact:
  phone: (186)285-7925
  address: 282 Kevin Brook
workers: 150
  1. Use {% const [key] %} Jekyll tag to render the content you need in the .html files:
<h3>{% const company_name %}</h3>
<p>We are more than {% const workers %} workers in our company located in {% const contact.address %}.</p>
<a href="tel:{% const contact.phone %}">Call us</a>
  1. After rendering the previous example, you will see the following code in the .html file:
<h3>Group Hirthe-Ritchie</h3>
<p>We are more than 150 workers in our company located in 282 Kevin Brook.</p>
<a href="tel:(186)285-7925">Call us</a>

3. Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

4. License

The gem is available as open source under the terms of the MIT License.