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.

getStaticProps overrides exportPathMap

See original GitHub issue

Bug report

Describe the bug

Adding getStaticProps overrides folder settings set within exportPathMap in next.config.js.

I’m essentially trying to get my html files to be output in /directory/index.html rather than /directory.html. Unfortunately even I set my exportPathMap to do so, as soon as the getStaticProps function is added in my script, the setting is overridden and the file will be output at directory.html

To Reproduce

git clone https://github.com/creativiii/next-js-export-bug
cd next-js-export-but
npm run build
npm run export

Then check the out directory.

Expected behavior

page-1 and page-2 should be respectively exported in /page-1/index.html and /page-2/index.html. Instead page-2 is exported as page-2.html.

System information

  • OS: [e.g. macOS, Windows]: WSL Ubuntu 20.04
  • Version of Next.js: [e.g. 6.0.2] 9.4.4
  • Version of Node.js: [e.g. 10.10.0] LTS 12

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
Timercommented, Jul 20, 2020

Have you tried enabling this option?

// next.config.js
module.exports = {
  exportTrailingSlash: true,
}
2reactions
furcancommented, Jul 22, 2021

getStaticProps is completely useless with next export. (Also exportPathMap)

I think the Next.js dev team is thinking the people around the world using the Next.js just to create a single “index.js” file, and print a “hello world!”

All the communication between the dev team and us is just like that: “We will not create a solution, use the Next.js just like that or else…”

Anyway, Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

exportPathMap - next.config.js
Warning: Using exportPathMap for defining routes with any getStaticPaths powered page is now ignored and gets overridden. We recommend not to use them...
Read more >
Bountysource
getStaticProps overrides exportPathMap.
Read more >
NextJS: How do I get exportPathMap page data? I don't see it ...
I have set up exportPathMap but I get an empty object when exporting getStaticProps from my component. I don't understand how I'm supposed ......
Read more >
Static HTML Export with i18n compatibility in Next.js
components/Link' + const getStaticProps ... info - Copying "static build" directory info - No "exportPathMap" found in ...
Read more >
Creating a Markdown Blog with Next.js - Tina.io
You can use getStaticProps to fetch data from an external api, ... don't have to worry about accidentally overriding a style somewhere else....
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