Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在next.js中省略html扩展名?_Next.js - Fatal编程技术网

如何在next.js中省略html扩展名?

如何在next.js中省略html扩展名?,next.js,Next.js,我正在使用next.js构建一个静态站点,我希望我的website.com/about.html能够像:website.com/about——我不知道为什么它会强迫我键入.html 即使我构建了我的项目:pages/about/index.js——它生成了一个about.html,而不是静态站点上的about/index.html。我在next的网站上找到了答案: module.exports = { exportTrailingSlash: true, } 如果您有NEXT.JS 9.

我正在使用next.js构建一个静态站点,我希望我的
website.com/about.html
能够像:
website.com/about
——我不知道为什么它会强迫我键入
.html


即使我构建了我的项目:
pages/about/index.js
——它生成了一个
about.html
,而不是静态站点上的
about/index.html

我在next的网站上找到了答案:

module.exports = {
  exportTrailingSlash: true,
}

如果您有NEXT.JS 9.5或更高版本,则可以使用它

看看这个NEXT.JS官方文档。

这是可行的,但有一个问题:当用户没有键入尾随斜杠时,会重定向到带有斜杠的URL。这种重定向需要花费时间,特别是在高延迟情况下。这是否回答了您的问题?
module.exports = {
  trailingSlash: true,
}