Aupajo / middleman-search_engine_sitemap

Tell search engines which pages are most important in your Middleman site.
MIT License
56 stars 6 forks source link

Redirects get included in sitemap, but they have "noindex, follow" metatag #11

Open komor72 opened 5 years ago

komor72 commented 5 years ago

Hello again. :) Just found another side-effect. Redirects created in config.rb like:

redirect 'tags/peperoni.html', to: 'tags/pepperoni.html'

do get included in sitemap (which is probably fine?), but the Middleman includes a "noindex, follow" metatag in generated HTML code:

<meta name="robots" content="noindex,follow" />

which is being considered as an error by Google Search. Anybody has an opinion on which is better: disable redirects being added to sitemap, or changing the Middleman template HTML-code for redirects? Or create a new config option in middleman-search_engine_sitemap?

komor72 commented 5 years ago

A workaround for this behavious can be easily implemented using the exclude_if option:

activate :search_engine_sitemap, default_change_frequency: "weekly", exclude_if: ->(resource) {
  resource.source_file.nil?
}

The reason is that dynamically generated redirects have no source_file attributes (proxies do have source_file set to proxy template source file). If you guys think this is enough, then we can close this issue. But maybe it would helpful to think, what's right.

Aupajo commented 5 years ago

Hey, sorry @komor72. I'm not maintaining this any more. It's been a few years since I used it myself, and I've lost touch with what's happening inside the Middleman codebase.