bridgetown
bridgetown copied to clipboard
feat: Support hreflang tags for i18n
Summary
What are your thoughts on adding support for hreflang tags so sites are generated with proper linking between pages. https://developers.google.com/search/docs/specialty/international/localized-versions#html
We currently have this helper in our sites
class Helpers::HreflangHelper < SiteBuilder
def build
helper :hreflang_tags_for do |resource|
site.tmp_cache["href_lang_#{resource.path}"] ||=
resource.all_locales.sum('') do |local_resource|
tag.link(
rel: 'alternate',
href: "#{site.config.host}#{local_resource.relative_url}",
hreflang: local_resource.data.locale
)
end.html_safe # rubocop:disable Rails/OutputSafety
end
end
end
Yeah, I love that idea! I'm about to dive back into the i18n stuff a bit to try to add Fast Refresh support, so I'll come back with a fresh perspective on how we could add this.