Jekyll tags that have spaces or multiple words

jekyll, liquid, ruby

Solution

You can use `url_encode` filter : `{{ tag | url_encode }}`.

Note that url_encode will turn a space into a + sign instead of a percent-encoded character. cf. Liquid doc

Problem

I'm using tags in Jekyll for my blog posts. The following is an example of tags I declare in the front matter in the Markdown file: ``` --- tags: [jekyll, tags, user experience] --- ``` The problem I have is that the "user experience" is rendered with a space, which breaks the link for the tag. I'd like to know if it's possible to have tags that have spaces or multiple words. This is what my code looks like: Markup with Ruby: ``` {% if page.tags.size > 0 %} <div class="post-tags"> <ul> {% for tag in page.tags %} <li><a href="/tags#{{ tag }}">{{ tag }}</a>{% if forloop.last == false %},{% endif %}</li> {% endfor %} </ul> </div> {% endif %} ``` Does anyone have any ideas on how I can do that? Thanks!

Original source

Related problems