File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed
src/components/shared/seo Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,6 @@ const shouldAnnouncementBannerBeShown = false;
12
12
13
13
const plugins = [
14
14
'gatsby-plugin-react-helmet' ,
15
- {
16
- resolve : `gatsby-plugin-react-helmet-canonical-urls` ,
17
- options : {
18
- siteUrl : process . env . GATSBY_DEFAULT_MAIN_URL ,
19
- noTrailingSlash : true ,
20
- } ,
21
- } ,
22
15
'gatsby-transformer-sharp' ,
23
16
'gatsby-plugin-sharp' ,
24
17
'gatsby-plugin-catch-links' ,
@@ -171,6 +164,17 @@ if (process.env.GATSBY_DRIFT_API) {
171
164
} ) ;
172
165
}
173
166
167
+ const autoCanonicalURL = false ;
168
+ if ( autoCanonicalURL ) {
169
+ plugins . push ( {
170
+ resolve : `gatsby-plugin-react-helmet-canonical-urls` ,
171
+ options : {
172
+ siteUrl : process . env . GATSBY_DEFAULT_MAIN_URL ,
173
+ noTrailingSlash : true ,
174
+ } ,
175
+ } ) ;
176
+ }
177
+
174
178
if (
175
179
process . env . ALGOLIA_ADMIN_KEY &&
176
180
process . env . GATSBY_ALGOLIA_APP_ID &&
Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ export const SEO = ({
40
40
const currentUrl = slug ? `${ docs } /${ slug } ` : docs ;
41
41
const currentImage = createMetaImagePath ( image , siteUrl , siteImage ) ;
42
42
43
+ const hrefLangRelAttributeHash = {
44
+ en : 'alternate' ,
45
+ es : 'alternate' ,
46
+ } ;
47
+ if ( slug && ( slug . startsWith ( 'es/' ) || slug === 'es' ) ) {
48
+ hrefLangRelAttributeHash . es = 'canonical' ;
49
+ } else {
50
+ hrefLangRelAttributeHash . en = 'canonical' ;
51
+ }
52
+
43
53
return (
44
54
< >
45
55
{ I18N_CONFIG . hideEsFromRobots &&
@@ -73,14 +83,14 @@ export const SEO = ({
73
83
< link
74
84
hrefLang = "en"
75
85
href = { `${ siteUrl } /docs${ pageTranslations . en . path } ` }
76
- rel = "alternate"
86
+ rel = { ` ${ hrefLangRelAttributeHash . en } ` }
77
87
/>
78
88
) }
79
89
{ pageTranslations && pageTranslations . es !== undefined && (
80
90
< link
81
91
hrefLang = "es"
82
92
href = { `${ siteUrl } /docs${ pageTranslations . es . path } ` }
83
- rel = "alternate"
93
+ rel = { ` ${ hrefLangRelAttributeHash . es } ` }
84
94
/>
85
95
) }
86
96
{ pageTranslations && (
You can’t perform that action at this time.
0 commit comments