I have a Rails 4 app with turbo-links enabled, but I can\'t get the meta tags to refresh when changing the page ( not a full refresh ) . I read that the meta-tags need to be inc
Have a look on meta-tags gem
"Using with pjax" section
I extend the current turbolinks js ;)
It will replace meta tags and canonical link!
https://github.com/philklei/turbolinks
It's a TurboLinks Problem
By design, Turbolinks basically keeps the <head>
of your page the same & calls the <body>
of your document via ajax if it's going to remain the same (you're using the same controller / action). It's some crazy thing to maintain application performance
Here is a good explanation of Turbolinks
I've had a similar problem to this with Javascript, and was able to use the Jquery-Turbolinks gem to keep JS rendering
For your meta tags, although I don't know a solution off hand, I managed to find a decent gem you might benefit from: MetaMagic. It allows you to define meta tags in the view, kind of like how the content_block facility works. This should be loaded on every http request
Turbolinks is designed to keep the <head>
tag the same and merely replaces the <body>
tag with the contents of the requested page via an AJAX request. Since your <meta>
tags are located in the <head>
, they won't be changed via a Turbolinks request.
From an SEO perspective, you don't need to worry about the <meta>
tags being updated on a Turbolinks request because the search engine crawlers will always do a full page request and won't execute the Turbolinks javascript.
From a user's perspective, the only tag in the <head>
that needs to change for each request is the <title>
tag, so special handling for that was built-in to Turbolinks itself.
This "issue" has been raised and shot down a couple times, each time being declared a non-issue by DHH himself, so I wouldn't count on this behavior changing any time soon.
See: