Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support hreflang tags for i18n #930

Open
jclusso opened this issue Oct 21, 2024 · 1 comment
Open

feat: Support hreflang tags for i18n #930

jclusso opened this issue Oct 21, 2024 · 1 comment

Comments

@jclusso
Copy link
Contributor

jclusso commented Oct 21, 2024

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
@jaredcwhite
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@jclusso @jaredcwhite and others