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

gatsby-plugin-sitemap not generating sitemap with default options when running yarn build #31903

Closed
JavierPiedra opened this issue Jun 14, 2021 · 10 comments · Fixed by #31963
Closed
Assignees
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@JavierPiedra
Copy link

JavierPiedra commented Jun 14, 2021

Description

When running yarn build gatsby-plugin-sitemap is generating following error:

 ERROR #11321  PLUGIN

"gatsby-plugin-sitemap" threw an error while running the onPostBuild lifecycle:

Page array from `query` wasn't found at `data.allSitePage.nodes`.
      Fix the custom query or provide a custom `resolvePages` function.
      https://www.gatsbyjs.com/plugins/gatsby-plugin-sitemap/#api-reference


  46 |             queryRecords = _yield$graphql.data;
  47 |             _context.next = 8;
> 48 |             return Promise.resolve(resolvePages(queryRecords)).catch(function (err) {
     |                                    ^
  49 |               return reporter.panic(_internals.REPORTER_PREFIX + " Error resolving Pages", err);
  50 |             });
  51 |

File: node_modules/gatsby-plugin-sitemap/gatsby-node.js:48:36



  Error: Page array from `query` wasn't found at `data.allSitePage.nodes`.
        Fix the custom query or provide a custom `resolvePages` function.
        https://www.gatsbyjs.com/plugins/gatsby-plugin-sitemap/#api-reference

However I'm using default options and when looking on the graphql query, it is actually generating the paths on the allSitePage query.

Steps to reproduce

Initialize a gatsby project:

  1. gatsby new test
  2. set node version to 12 nvm use 12
  3. add gatsby-plugin-sitemap yarn add gatsby-plugin-sitemap
  4. yarn build

Expected result

gatsby-plugin-sitemap creates a sitemap

Actual result

Not finishing the build

Environment


  System:
    OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
  Languages:
    Python: 3.9.1 - /home/javierpiedra/miniconda3/bin/python
  Browsers:
    Chrome: 91.0.4472.101
    Firefox: 89.0
  npmPackages:
    gatsby: ^3.6.2 => 3.6.2 
    gatsby-plugin-gatsby-cloud: ^2.6.1 => 2.6.1 
    gatsby-plugin-image: ^1.6.0 => 1.6.0 
    gatsby-plugin-manifest: ^3.6.0 => 3.6.0 
    gatsby-plugin-offline: ^4.6.0 => 4.6.0 
    gatsby-plugin-react-helmet: ^4.6.0 => 4.6.0 
    gatsby-plugin-sharp: ^3.6.0 => 3.6.0 
    gatsby-plugin-sitemap: ^4.3.1 => 4.3.1 
    gatsby-source-filesystem: ^3.6.0 => 3.6.0 
    gatsby-transformer-sharp: ^3.6.0 => 3.6.0 
  npmGlobalPackages:
    gatsby-cli: 3.7.0
@JavierPiedra JavierPiedra added the type: bug An issue or pull request relating to a bug in Gatsby label Jun 14, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 14, 2021
@KingKerr
Copy link

Getting the exact same error when running gatsby build. Gatsby version is 3.6.0.

@lnikell
Copy link

lnikell commented Jun 15, 2021

In my case build is successfully finished by there is no sitemap.xml any longer in the public folder.

@KingKerr
Copy link

Getting the exact same error when running gatsby build. Gatsby version is 3.6.0.

Ending up following the steps outlined here to wrap up the build:
#31095 (comment)

@sandro768
Copy link

Same issue here

@LekoArts LekoArts added status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 16, 2021
@LekoArts
Copy link
Contributor

LekoArts commented Jun 16, 2021

Following your reproduction steps I'm also seeing this.

In my case build is successfully finished by there is no sitemap.xml any longer in the public folder.

That's working as intended. Look for a sitemap-index.xml and sitemap-0.xml (inside a sitemap folder if you didn't change the defaults).

@LekoArts
Copy link
Contributor

The real error message was hidden. The issue is that siteUrl was missing inside siteMetadata of your gatsby-config.js.

@sandro768
Copy link

@LekoArts I've got siteMetadata defined in config but still got this issue.

@sandro768
Copy link

Downgraded to 3.3.0

"gatsby-plugin-sitemap": "^3.3.0"

Working fine here.

@sandren
Copy link

sandren commented Jun 18, 2021

Downgraded to 3.3.0

"gatsby-plugin-sitemap": "^3.3.0"

Working fine here.

Thank you. Downgrading to v3 resolved the issue for me as well. 😀

@rjsmith2
Copy link

on Gatsby 3.9.0, downgrading from 4.5.0 to 3.3.0 fixed it for me as well. I already have siteMetadata.siteUrl defined

snamiki1212 added a commit to snamiki1212/gatsby-starter-lunash that referenced this issue Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants