Include canonical link in project meta tags

This will tell crawlers that this page and all its exact duplicates (/fullscreen, /editor, /embed, etc...) should be considered the same and use the project page as the canonical crawled page. We had an issue before where by not selected a canonical, google was considering all the project pages duplicates :(
This commit is contained in:
Paul Kaplan 2019-09-20 08:59:26 -04:00 committed by GitHub
parent 8f84051a86
commit aa6e85d863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@ const Helmet = require('react-helmet').default;
const projectShape = require('./projectshape.jsx').projectShape;
const Meta = props => {
const {title, instructions, author} = props.projectInfo;
const {id, title, instructions, author} = props.projectInfo;
// Do not want to render any meta tags unless all the info is loaded
// Check only author (object) because it is ok to have empty string instructions
@ -29,6 +29,10 @@ const Meta = props => {
content={truncatedInstructions}
property="og:description"
/>
<link
rel="canonical"
href={`https://scratch.mit.edu/projects/${id}`}
/>
</Helmet>
);
};