kpumuk / meta-tags

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

Release 2.1.0 force crops site title if whole title is longer than 70 characters #99

Closed zamakkat closed 8 years ago

zamakkat commented 8 years ago

The changes introduced in release 2.1.0 made some breaking changes when enforcing the whole site title to be no more than 70 characters. For example if I had a page title Privacy Policy and a site title Website Name - The very best website name in the whole Universe I would expect to get this:

Privacy Policy | Website Name - The very best website name in the whole Universe

but instead I get something like this:

Priv | Website Name - The very best website name in the whole Universe

After a while of looking around I realized it was a "feature". Ref: https://github.com/kpumuk/meta-tags/commit/1c4ed2157e4a869dc57ed521fbe562522c872ecf. Although I understand that this is SEO "best practices", I think it makes a lot of sense to make it optional or at least warn with a depreciation message on upgrade. And maybe just truncate from the end instead of truncating the page title?

zamakkat commented 8 years ago

Oh an for those looking for a fix, you just need to add an initializer. Create a file config/initializers/meta_tags.rb with this content:

MetaTags.configure do |config|
  # How many characters to truncate title to.
  config.title_limit = 70

  # How many characters to truncate description to.
  config.description_limit = 160

  # How many characters to truncate keywords to.
  config.keywords_limit = 255

  # Keywords separator - a string to join keywords with.
  config.keywords_separator = ', '
end

Change the title_limit accordingly to what you need :)

kpumuk commented 8 years ago

Considering closed :-)