Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The url of the sitemap should match the actual url #5324

Closed
wants to merge 1 commit into from
Closed

The url of the sitemap should match the actual url #5324

wants to merge 1 commit into from

Conversation

tam315
Copy link
Contributor

@tam315 tam315 commented May 8, 2018

Since gatsby forces the URL to be in lowercase letters, the URL of the site map must also be lowercase.


When use gatsby with markdowns, filename may contain UpperCase letter.

On this situation, gatsby-plugin-sitemap generates the url with UpperCase,
and Gatsby generates path with lowercase.

As a result, search engine claims that sitemap's url is not valid.

They say "There is no canonical tag in the URL of the Sitemap"
as they indexes the actual (lowercase) URL and
thinks that the URL of the site map is not canonical.


e.g.

Filename:
2018-04-09-AboutJamStack.md

Sitemap URL:
https://www.some.org/2018-04-09-AboutJamStack/ (301 redirected to actual url)

Actual URL:
https://www.some.org/2018-04-09-aboutjamstack/

@gatsbybot
Copy link
Collaborator

Deploy preview for using-drupal ready!

Built with commit 3dbf64d

https://deploy-preview-5324--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

Deploy preview for gatsbygram ready!

Built with commit 3dbf64d

https://deploy-preview-5324--gatsbygram.netlify.com

@KyleAMathews
Copy link
Contributor

Hmmm I wasn't aware that Gatsby forced URLs to be lowercase? I've built sites with uppercase URLs and it worked fine. Perhaps there's something else going on?

@tam315
Copy link
Contributor Author

tam315 commented May 8, 2018

thanks @KyleAMathews

I checked and realized that redirection occurs only in production enviroment (Netlify).
redirection not happens on the localhost,

Also, I noticed that converting to lowercase should be done with my custom onCreateNode,
not in sitemap-plugin.

so, this PR has become useless, I close this. sorry to mess up.

exports.onCreateNode = ({ node, getNode, boundActionCreators }) => {
  const { createNodeField } = boundActionCreators;

  if (node.internal.type === 'MarkdownRemark') {
    const slug = createFilePath({ node, getNode, basePath: '_posts/blog' });

    createNodeField({
      node,
      name: 'slug',
      value: slug.toLowerCase(),
    });
  }
};

@tam315 tam315 closed this May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants