Search code examples
pythonpelican

Pelican: join Tags with comma


I create a static website by Pelican, and currently in the theme the keywords is created from tag, like:

{% for tag in articles.tags %}
<meta name="keywords" content="{{ tag }}"/>
{% endfor %}

In this case, there will be multiple lines. What I want is one line with the tag joining by ',', just like: <meta name="keywords" content="word1,word2,word3"/>.
Thanks.


Solution

  • As i understand it right, Pelican uses Jinja template engine.

    So this will do:

    <meta name="keywords" content="{{ articles.tags|join(',') }}"/>
    

    Documentation for this build-in filter: join()