Accessing content.keyword section for pages

Hi,
currently I am working on a solution to add automatically related content from our website (not only related blog posts) into a related content carousel. At this moment this module works with selecting following functionality:

  • related blog posts (dynamically) or
  • recent blog posts (dynamically) and not required
  • related pages (manually, like pillar pages, white papers, event pages)

At this point I started thinking about adding related pages also dynamically by keywords/tags as it works on the blog. My first idea was to use the meta-keyword functionality, wich is not the best solution for non-developers, but might work. So I started to fill the additional head html under advanced website settings with the meta key

<meta name="keywords" content="dispatching, test">

This way I could access the keywords in my modules. But I feel like this is a bit dirty and I asked myself if it would be possible to insert the unused JSON-branches like content.keywords, content.meta_keywords, … I found in the developer infos, which are empty or null. I would also appreciate a suggestion to make the keywords-input easier for content editors - even if we could input the keywords by adding them into a module. Any ideas are welcome!
Thanks in advance!
Fabian

Hey @FabianRichter

Thank you for the information provided. I’ll tag a few of our experts that can share their knowledge with you.

Hey @Anton @Reg @dennisedson could you please share your thoughts with @FabianRichter?

Thank you

Sharon

Hi @FabianRichter,

to make your content editors lifes easier a possible solution could be:

create a new module(not global) with a single text field(not rich-text) and enable the repeater function in it. I’ve called mine “keyword”

paste following code into the HTML+Hubl(important) section of the module:

<script>$('head').append( '<meta name="keywords" content="">' );</script>

copy the snippet from the text field you’ve created and paste it below the script.

It should look like this:

<script>$('head').append( '<meta name="keywords" content="">' );</script>
{% for item in module.keyword %}
	{% inline_text field="keyword" value="{{ item }}" %}
{% endfor %}

change the code to:

<script>$('head').append( '<meta name="keywords" content="{% for item in module.keyword %}{ item }}{% endfor %}">' );</script>

now your content editors could easily add a keyword per repeater function… BUT… there are a few small steps left.

First: you’ll have to seperate each keyword from another.
you can do this by adding a “comma” after the item

<script>$('head').append( '<meta name="keywords" content="{% for item in module.keyword %}{ item }},{% endfor %}">' );</script>

Second/Last: you’ll have to put the module into the template. There are several ways to achieve this. If you’re using the drag&drop template builder simply add it to the footer section of each template. If you’re using html templates, copy the module snippet.

best,
Anton

Hi @Anton,
that sounds really good. I will try that and give you a response soon.
Thank you!
Fabian