I
I
IvanN7772015-04-02 20:59:17
Search Engine Optimization
IvanN777, 2015-04-02 20:59:17

How to organize SEO (tags on Rails)?

Rails routing is quite beautiful, however.
It is not entirely clear to me how to store in the database and call the appropriate title and meta tags.
How to determine which page I'm on.
Of course, you can move the title and seo tags out of the main template into a display for a specific page. But it's definitely not a good option.
If I have news, yes, I can call the corresponding title, meta data from the description by the id of the news.
But this is if I put the title and meta on the display page.
But ideally, it would be nice to place them in the template.
To display for all pages.
It's a nice gem, but still just pretty output
https://github.com/lassebunk/metamagic
You can analyze the URL of the page and, depending on it, call the appropriate SEO data.
But it seems to me that Rails already has this?
And I don't have to write it from scratch.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
B
Boris Penkovsky, 2015-04-02
@IvanN777

make a helper that will put down the necessary information depending on the controller / action and call the helper in the layout

A
Anton Dyachuk, 2015-04-07
@Renius

The problem has no general solution, congratulations.
At one time, I took it to a handler that generated tags based on controller rules, collected collections of objects. Called in the app controller and yelded in templates. The texts were stored in I18n.

A
Alexey, 2015-04-03
@fuCtor

As mentioned above, write your own helper, then, either based on the data from the params where these controllers and actions are stored, display the necessary data. Or explicitly expose them in the controller, and then display them.

K
koww, 2017-11-21
@koww

There is a great gem meta-tags
In addition to the main meta tags, it also includes all popular markups - Open Graph, Twitter Card, Pagination links, image_src links, amphtml links

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question