How do I omit the html extension in next.js?

蹲街弑〆低调 提交于 2021-01-27 15:55:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!