Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
fix(SEO): rel=alternate
Browse files Browse the repository at this point in the history
  • Loading branch information
CanRau committed Dec 18, 2019
1 parent 89e250c commit 0a827b5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/components/MainLayout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const MainLayout = props => {
menuItems,
})
const urlParams = QS.parse()
const translationEn = translations.find(t => t.frontmatter.lang === `en`)

// const polyfills = [...globalPolyfills, ...localPolyfills]

Expand Down Expand Up @@ -203,17 +204,15 @@ const MainLayout = props => {
href={`/${lang}/sitemap.xml`}
/>

{[`/en`, `/de`].includes(location.pathname) && (
<link
rel="alternate"
href={site.siteMetadata.siteUrl}
hrefLang="x-default"
/>
)}
{translations.map(({ frontmatter: t }) => (
<link
rel="alternate"
href={site.siteMetadata.siteUrl + translationEn.fields.url}
hrefLang="x-default"
/>
{translations.map(({ frontmatter: t, fields }) => (
<link
rel="alternate"
href={`${site.siteMetadata.siteUrl}/${t.lang}/${t.slug}`}
href={`${site.siteMetadata.siteUrl}${fields.url}`}
hrefLang={t.lang}
key={t.lang}
/>
Expand Down

0 comments on commit 0a827b5

Please sign in to comment.