ethercreative / seo

SEO utilities including a unique field type, sitemap & redirect manager
MIT License
267 stars 95 forks source link

Keywords are not rendered in template #446

Closed Kota-M closed 1 year ago

Kota-M commented 1 year ago

Description

I would like to insert keywords which are set in Craft back-end, with the plugin. However, keywords are not rendered in the template. How can I render them?

I already tried it, but "Array to string conversion" error occurs. <meta name="keywords" content="{{ seo.keywords|join(', ') }}" />

Additional info

Kota-M commented 1 year ago

I found it by myself. My additional code for meta.twig is;

{% set keywords_string = "" %}
{% set is_first_keyword = true %}
{% for item in seo.keywords %}
    {% if is_first_keyword %}
        {% set keywords_string = item.keyword %}
        {% set is_first_keyword = false %}
    {% else %}
        {% set keywords_string = keywords_string ~ ", " ~ item.keyword %}
    {% endif %}
{% endfor %}
{% if keywords_string|length > 0 %}
    <meta name="keywords" content="{{ keywords_string }}" />
{% endif %}
alexjcollins commented 1 year ago

@Kota-M Thank you for following up with your solution. I'm going to close this issue, but if you have any other questions or issues, do let us know.