Closed rsiddle closed 7 years ago
Hey. MetaTags does not strip any characters if they fit into the limit (70 characters by default). Could you add something like
<pre><%= @page.meta_title.inspect %></pre>
to your page and post the result here for me to reproduce/investigate?
Tried:
set_meta_tags(
title: 'Overriding the title | Example Site',
)
display_meta_tags(
site: 'My website',
reverse: true,
)
and it is rendering:
<title>Overriding the title | Example Site | My website</title>
The only way to reproduce the issue you're seeing is here:
set_meta_tags(
title: 'Overriding the title very long title something wtf | Example Site',
)
display_meta_tags(
site: 'My website',
prefix: false,
reverse: true,
)
Renders:
<title>Overriding the title very long title something wtf || My website</title>
This is because the result title is reaching the limit (70 chars), and page title gets truncated. There are two options:
config.title_limit
config.truncate_site_title_first
Global settings file can be generated using rails generate meta_tags:install
One small correction: if the string was truncated as is, on the character break, the result would have been Overriding the title very long title something wtf | Exam | My website
. But MetaTags tries to break title on word edges, so the truncated word Exam
does not appear in the result.
@rsiddle hey. could you confirm that the issue is resolved for you? :-)
Closing the issue. If you have any more questions - feel free to re-open.
Using version 2.6.0
The output is:
If I change to use
@page.title
, it seems to work fine.The output is:
@page.meta_title
returns "Overriding the title | Example Site"I would expect this to output "Overriding the title | Example Site | My website"
It appears as though the string is being sanitized and removes everything past the pipe
|
character. I seetitle
can accept an Array so it automatically adds the separator if needs be. It seems like odd behaviour to strip past the pipe/separator in a string though.