question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sitemap does not contain links to all pages

See original GitHub issue

Describe the bug My project has 5 pages. Generated sitemap has only 2.

To Reproduce I am creating new sitemap using next-sitemap --config next-sitemap.config.js

Expected behavior I expected sitemap to contain links to all 5 pages.

Additional context next-sitemap.config.js:

module.exports = {
	siteUrl: process.env.SITE_URL || 'https://apps.is',
	generateRobotsTxt: true,
}

The generated sitemap:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url><loc>https://apps.is</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-05-17T15:46:41.100Z</lastmod></url>
<url><loc>https://apps.is/our-way</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-05-17T15:46:41.100Z</lastmod></url>
</urlset>```

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
LiangYingCcommented, Sep 3, 2021

Thanks @abzeede and @sanderfish answer to solve this problem.

Let me try to explain more after tracing source code by myself.

If we run next-sitemap of script, it will run /bin/next-sitemap file and load cli.

So, we can see what happen at /src/cli.ts and focus on

// Get runtime paths
const runtimePaths = getRuntimePaths(config)

when we read more detail about getRuntimePaths at /src/path/index.ts, we can realize it return

{
    BUILD_MANIFEST: getPath(config.sourceDir!, 'build-manifest.json'),
    PRERENDER_MANIFEST: getPath(config.sourceDir!, 'prerender-manifest.json'),
    EXPORT_MARKER: getPath(config.sourceDir!, 'export-marker.json'),
    ......
  }

we can get file paths about build-manifest.json, prerender-manifest.json and export-marker.json that all files will be create after next build and will be used to create url set at /src/cli.ts.

To conclude, cause next-sitemap need to use files will be create after next build to create sitemap, so we need to run next build before run the next-sitemap script.

Hope to help understanding why need to do

{
  "build": "next build && next-sitemap"
}

not

{
  "build": "next-sitemap && next build"
}

Thanks.

2reactions
sanderfishcommented, Jul 7, 2021

Had the same issue. Chaining the build script instead of using postbuild works for me:

{
  "build": "next build && next-sitemap"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sitemap tool fails to find all URLs in my site [closed]
The sitemap generator will start at the root and follow all links on the pages and so on until it has exhausted all...
Read more >
Why my sitemap doesn't have any link pages after generated?
It seems that your website is dynamic website so websites like xmlsitemaps.com can not crawl it. you will have to ask you developer...
Read more >
Why are some website pages not included or missing ... - Quora
Some website pages are not included or missing in a sitemap because they don't have any content or have a low amount of...
Read more >
Sitemap has no links - WordPress.org
I just noticed the sitemap is almost blank. Even after changing a few settings like the caching of the sitemap, there still are...
Read more >
Should XML sitemaps include *all* pages or just the deeper ...
The idea is that if your site does not provide crawlable navigation, Google can use your sitemap to crawl your site. There are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found