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.

Static export of folders with index file creates html file with name of the folder

See original GitHub issue

Bug report

Describe the bug

With Next 9 the new default is exporting paths as html files with the name of the path (see here).

However, this also has extended to folder with an explicit index file in them.

For example pages/folder1/index.jsx will get outputted as out/folder1.html this leads to webservers displaying the contents of that folder instead of the html file you would expect.

To Reproduce

  1. Clone https://github.com/jaredpereira/next-export-bug-repro
  2. npm i && npm run export
  3. Inspect out or serve w/ now.sh

Expected behavior

The expected behavior is for pages/folder1/index.jsx , next export should output out/folder1/index.html

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

32reactions
devisschercommented, Jul 26, 2019

I think this is mentioned here. https://github.com/zeit/next.js#usage

You can add exportTrailingSlash option to your Next config and preserve the same functionality as before Next 9.

// next.config.js
module.exports = {
  exportTrailingSlash: true,
}
2reactions
jaredpereiracommented, Jul 26, 2019

@devisscher exportTrailingSlash results in every file being given it’s own folder with an index.html inside. That does resolve the problem in that it’ll work when served but it is a bit of an odd work around. The expected outcome here I think would be a 1:1 mapping of input files to output files, where index files are created when they exist in the input. I may be misunderstanding something obvious here though!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to keep nextjs index files inside their respective folders ...
this post is quite old but I just faced this issue today, in your next.config.js make sure to add trailingSlash: true , like:...
Read more >
Advanced Features: Static HTML Export | Next.js
During next build , getStaticProps and getStaticPaths will generate an HTML file for each page in your pages directory (or more for dynamic...
Read more >
Configuring an index document - Amazon Simple Storage ...
Create an index.html file. ... Save the index file locally. The index document file name must exactly match the index document name that...
Read more >
HTML Files are missing - WordPress.org
Checking if web server can read from Temp Files Directory: /var/www/html/wp-content/plugins/simply-static-master/static-files/ ⟶ x Fail.
Read more >
Publishing Org-mode files to HTML
The first file we add to that folder (and to subdirectories later on) is called index.org . This name was choosen, since Org...
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