Answer the question
In order to leave comments, you need to log in
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
make a helper that will put down the necessary information depending on the controller / action and call the helper in the layout
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.
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question