From 5294936667c99c461a9d8de75b3ad89e75795cd6 Mon Sep 17 00:00:00 2001 From: Hassaan Pasha Date: Tue, 3 Mar 2020 20:27:53 +0500 Subject: [PATCH] fix(learn): prevent indexing learn pages on search engines (#38260) Co-authored-by: mrugesh <1884376+raisedadead@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams --- client/gatsby-config.js | 3 ++- client/src/components/layouts/Learn.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/client/gatsby-config.js b/client/gatsby-config.js index 7e5076c75e..94355d0ebb 100644 --- a/client/gatsby-config.js +++ b/client/gatsby-config.js @@ -1,4 +1,5 @@ const path = require('path'); +const config = require('./config/env'); const { buildChallenges, @@ -11,7 +12,7 @@ const curriculumIntroRoot = path.resolve(__dirname, './src/pages'); module.exports = { siteMetadata: { title: 'freeCodeCamp', - siteUrl: 'https://www.freecodecamp.org' + siteUrl: config.homeLocation }, plugins: [ 'gatsby-plugin-react-helmet', diff --git a/client/src/components/layouts/Learn.js b/client/src/components/layouts/Learn.js index a24bdb9ce1..b5f92ac015 100644 --- a/client/src/components/layouts/Learn.js +++ b/client/src/components/layouts/Learn.js @@ -2,7 +2,7 @@ import React, { Fragment, Component } from 'react'; import PropTypes from 'prop-types'; import { createSelector } from 'reselect'; import { connect } from 'react-redux'; - +import { Helmet } from 'react-helmet'; import { Loader } from '../../components/helpers'; import { userSelector, @@ -41,6 +41,13 @@ class LearnLayout extends Component { this.props.tryToShowDonationModal(); } + componentWillUnmount() { + const metaTag = document.querySelector(`meta[name="robots"]`); + if (metaTag) { + metaTag.remove(); + } + } + render() { const { fetchState: { pending, complete }, @@ -59,6 +66,9 @@ class LearnLayout extends Component { return ( + + +
{children}