Adding Both Single-Word and Multi-Word Tags to a Jekyll Post
If we want to add both single-word and multi-word tags to our posts, here is how to do it.
Jekyll lets us set tags in two ways, with either the tag or the tags variable in the post’s front matter. With the tag variable, whatever we set it to, will be a single tag. For example
tag: ruby on railswill add the single tag ruby on rails, with spaces included.
However, the line
tags: ruby on railswill add three distinct tags to our post: ruby, on, and rails.
What should we do if we want to add, for example, both ruby and ruby on rails as tags? We can’t use any of the above methods, but there’s a way: yaml lists.
We can write it in two styles, either with each tag on its own line, indented, starting with a dash and a space:
tags:
- ruby
- ruby on railsor on a single line, with square brackets:
tags: [ruby, ruby on rails]Thanks for reading! If you have any comments, additions, or corrections, feel free to reach me via e-mail.