Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
next.js - directory structure of exported site

hoping a Next.js magician could help me with this, or at least just tell me flat out if it isn't possible.

We have a site which is compiled down into static files. These will be served from S3.

When I run next export, everything builds correctly, but I had hoped to be able to directly access subpages without adding the .html extension. I assumed (wrongly) that next built pages into directories, and dropped an index.html into that directory.

The setup on the dev side is fairly simple. Each component has a directory, eg "some-component", with an index.js which exports the named component from an adjacent file like "some-component.js".

This all works if I start at the site root - I can navigate to, eg, /components/some-component without worrying about the extension.

Next has created a some-component directory, but the file inside that is still just called some-component.html. So if I hit that url from the browser, it obviously 404s.

Is there any way to get next to spit out index.html's into the directories, so browsing directly to the directory (try saying that after a drink) works? Or am I barking up the wrong tree?

I know there are other solutions to this, particularly for s3, but figured it was worth asking about.

Cheers!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Next.js has a trailingSlash setting that should work for you:

// next.config.js
module.exports = {
  trailingSlash: true,
}

When this setting is true, and using something like ./pages/products/shoes.jsx as an example, a directory named after the .jsx file (shoes) is created and that .jsx file then becomes an index.html file inside that directory, i.e., href="/products/shoes/". Your server will send that path's index.html (or can be configured to if it doesn't already) even when index.html isn't specified in the href.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda