From 242a9a6c29a2bf0fc253a9d82372dc0289d33e15 Mon Sep 17 00:00:00 2001 From: Sam Nixon Date: Tue, 1 Oct 2024 11:52:39 +0200 Subject: [PATCH 1/2] Add canonical links to header --- src/components/seo.js | 100 ++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 39 deletions(-) diff --git a/src/components/seo.js b/src/components/seo.js index 27d06f0a1..887e543ae 100644 --- a/src/components/seo.js +++ b/src/components/seo.js @@ -27,45 +27,65 @@ const SEO = ({ title, description = '', lang = 'en', headerImage = '', meta = [] const metaDescription = description || site.siteMetadata.description; const twitterHandle = get(site, 'siteMetadata.social.twitter', 'roadiehq'); const ogImageUrl = headerImage || `${site.siteMetadata.siteUrl}${roadieLogo}`; - const ogImageAlt = 'The Roadie logo. A cube in isometric projection with 3 fins cut into the right face. The word Roadie is below.'; + const ogImageAlt = + 'The Roadie logo. A cube in isometric projection with 3 fins cut into the right face. The word Roadie is below.'; - const defaultMeta = [{ - name: `description`, - content: metaDescription, - }, { - property: `og:title`, - content: title, - }, { - property: `og:description`, - content: metaDescription, - }, { - property: `og:type`, - content: `website`, - }, { - property: `og:image`, - content: ogImageUrl, - }, { - name: `twitter:card`, - content: `summary`, - }, { - name: `twitter:site`, - content: twitterHandle, - }, { - name: `twitter:image`, - content: ogImageUrl, - }, { - name: `twitter:image:alt`, - content: ogImageAlt, - }, { - name: `twitter:creator`, - content: twitterHandle, - }, { - name: `twitter:title`, - content: title, - }, { - name: `twitter:description`, - content: metaDescription, - }]; + // Construct the canonical URL dynamically based on the siteUrl and current page's path + const canonicalUrl = + typeof window !== 'undefined' + ? `${site.siteMetadata.siteUrl}${window.location.pathname}` + : site.siteMetadata.siteUrl; // Fallback to siteUrl during server-side rendering + + const defaultMeta = [ + { + name: `description`, + content: metaDescription, + }, + { + property: `og:title`, + content: title, + }, + { + property: `og:description`, + content: metaDescription, + }, + { + property: `og:type`, + content: `website`, + }, + { + property: `og:image`, + content: ogImageUrl, + }, + { + name: `twitter:card`, + content: `summary`, + }, + { + name: `twitter:site`, + content: twitterHandle, + }, + { + name: `twitter:image`, + content: ogImageUrl, + }, + { + name: `twitter:image:alt`, + content: ogImageAlt, + }, + { + name: `twitter:creator`, + content: twitterHandle, + }, + { + name: `twitter:title`, + content: title, + }, + { + name: `twitter:description`, + content: metaDescription, + }, + ]; return ( + > + + ); }; From 564ca705e01b0835cf2fd0f0e381f94153a41257 Mon Sep 17 00:00:00 2001 From: Sam Nixon Date: Tue, 1 Oct 2024 11:52:52 +0200 Subject: [PATCH 2/2] Removed paths from disallow --- gatsby-config.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index fabeb3ddb..cceb1428d 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -77,18 +77,6 @@ const DISLALLOW_LIST = [ '/docs/getting-started/adding-a-catalog-item/aws-s3/', '/docs/getting-started/adding-a-catalog-item/azure-devops/', '/docs/getting-started/adding-a-catalog-item/roadie-cli/', - - // Referrals shouldn't be indexed - '/*?referringPathname=', - - // UTM tags shouldn't be indexed - '/*?*utm_campaign=', - '/*?*utm_medium=', - '/*?*utm_content=', - '/*?*utm_source=', - - // refs shouldn't be indexed. - '/*?*ref=', ]; // Only environment variables prefixed with GATSBY_ are available in the runtime. Here we turn