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

[1.0] gatsby-plugin-sitemap does not work #1271

Closed
chiedo opened this issue Jun 27, 2017 · 8 comments
Closed

[1.0] gatsby-plugin-sitemap does not work #1271

chiedo opened this issue Jun 27, 2017 · 8 comments

Comments

@chiedo
Copy link

chiedo commented Jun 27, 2017

Whenever I have the sitemap plugin activated, the build doesn't work.

The error I get from the gatsby-starter-blog site on the 1.0 branch after adding the plugin exactly as shown in the documentation.

A plugin returned an error

Error: GraphQLError: Unknown argument "sortBy" on field "allMarkdownRemark" of type "RootQueryType". Did you mean "sort"?, GraphQLError: Unknown argument "frontmatter" on field "allMarkdownRemark" of type "RootQueryType".
@KyleAMathews
Copy link
Contributor

Looks like you're using an older version of the plugin. Check you're on the latest beta.

Also you can always pass in a custom query if the default query isn't working https://github.com/gatsbyjs/gatsby/blob/1.0/packages/gatsby-plugin-sitemap/src/internals.js

@KyleAMathews
Copy link
Contributor

There's also an example site for this plugin.

https://github.com/gatsbyjs/gatsby/tree/1.0/examples/sitemap

@chiedo
Copy link
Author

chiedo commented Jun 27, 2017

Weird @KyleAMathews

I'm on @next. Maybe I'm doing something dumb. I'll revisit on a fresh mind.

@chiedo
Copy link
Author

chiedo commented Jun 27, 2017

Thanks for your quick responses by the way @KyleAMathews :) Great work on this project

@chiedo
Copy link
Author

chiedo commented Jun 27, 2017

It just clicked @KyleAMathews. Got it working!

I was making incorrect assumptions about the default query even after looking at it in the source code.

I personally think it would be better if the default query didn't have the filter in the query. What do you think? If you agree, I'll remove it and do a PR, that way it would work out the box for more people.

I ultimately had to remove the draft filter.

I ended up with this

    {
      resolve: 'gatsby-plugin-sitemap',
      options: {
        query: `
        {
          site {
            siteMetadata {
              site_url
            }
          }
          allMarkdownRemark(
            limit: 1000,
          ) {
            edges {
              node {
                fields {
                  slug
                }
              }
            }
          }
        }
      `}
    },

@KyleAMathews
Copy link
Contributor

There's this #1131

@chiedo
Copy link
Author

chiedo commented Jun 27, 2017

Perfect @KyleAMathews

@chiedo chiedo closed this as completed Jun 27, 2017
@chiedo
Copy link
Author

chiedo commented Jun 27, 2017

What would you think about this default? This is what I'm using on my site now so all my pages are included in the sitemap @KyleAMathews as opposed to just the blog page

        query: `
              {
          site {
            siteMetadata {
              site_url
            }
          }
          
          allSitePage(
            limit: 1000000000,
            filter: {
              path: {ne: "/dev-404-page/"}
            }
          ) {
            edges {
              node {
                path
              }
            }
          }
        }`,
        serialize: ({ site, allSitePage }) =>
          allSitePage.edges.map(edge => {
            return {
              url: site.siteMetadata.site_url + edge.node.path,
              changefreq: 'daily',
              priority: 0.7,
            }
        }),

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

No branches or pull requests

2 participants