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
- Add the following to your site's Gemfile:
gem 'jekyll_constant_values', group: :jekyll_plugins
- Run
bundle installin your command line:
$ bundle install
- Create a new YAML file called
constants.ymlunder 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.ymlfile this way:
constants: your-custom-name
2. Usage
- 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
- Use
{% const [key] %}Jekyll tag to render the content you need in the.htmlfiles:
<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>
- After rendering the previous example, you will see the following code in the
.htmlfile:
<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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
4. License
The gem is available as open source under the terms of the MIT License.