问题
I'm building a static site using next.js, and I want my website.com/about.html
to work just as: website.com/about
-- I'm not sure why it's forcing me to type .html
.
Even if I structure my project: pages/about/index.js
-- it generates a about.html
instead of about/index.html
on the static site.
回答1:
I found the answer on next's website:
module.exports = {
exportTrailingSlash: true,
}
https://nextjs.org/docs/api-reference/next.config.js/exportPathMap#adding-a-trailing-slash
回答2:
module.exports = {
trailingSlash: true,
}
You can use it if you have NEXT.JS 9.5 or higher versions.
Take a look at this NEXT.JS official document. https://nextjs.org/docs/api-reference/next.config.js/trailing-slash
来源:https://stackoverflow.com/questions/62866083/how-do-i-omit-the-html-extension-in-next-js