kpumuk / meta-tags

Search Engine Optimization (SEO) for Ruby on Rails applications.
MIT License
2.73k stars 275 forks source link

Merge meta tags #100

Closed toobulkeh closed 8 years ago

toobulkeh commented 8 years ago

Is there a preferred way to merge meta tags?

For example we have a list of 20+ keywords we want included on every page, but each page also has a few specific ones added to it (dynamic, based on the content).

Thanks!

toobulkeh commented 8 years ago

I ended up with this code in my layouts (HAML):

- set_meta_tags keywords: "#{meta_tags[:keywords] + ", " if meta_tags[:keywords]}#{t('keywords').join(", ")}"
= display_meta_tags

with this (the list of keywords on every page) in my en.yml:

en:
  keywords:
    - word1
    - word2
    - word3

If anyone else has a cleaner way to do this (or if this is supported by this gem) please let me know!

LeEnno commented 8 years ago

You may shorten it to something like

- set_meta_tags keywords: ((meta_tags[:keywords] || []) + t('keywords')).join(', ')
= display_meta_tags

And you may close the issue, since I think is an acceptable way of merging keywords :)