【发布时间】:2020-07-12 20:21:25
【问题描述】:
我正在使用 next.js 构建一个静态站点,并且我希望我的 website.com/about.html 像:website.com/about 一样工作——我不知道为什么它会强迫我输入 .html。
即使我构建了我的项目:pages/about/index.js——它也会在静态站点上生成 about.html 而不是 about/index.html。
【问题讨论】:
标签: next.js
我正在使用 next.js 构建一个静态站点,并且我希望我的 website.com/about.html 像:website.com/about 一样工作——我不知道为什么它会强迫我输入 .html。
即使我构建了我的项目:pages/about/index.js——它也会在静态站点上生成 about.html 而不是 about/index.html。
【问题讨论】:
标签: next.js
我在next的网站上找到了答案:
module.exports = {
exportTrailingSlash: true,
}
https://nextjs.org/docs/api-reference/next.config.js/exportPathMap#adding-a-trailing-slash
【讨论】:
module.exports = {
trailingSlash: true,
}
如果您有 NEXT.JS 9.5 或更高版本,则可以使用它。
看看这个 NEXT.JS 官方文档。 https://nextjs.org/docs/api-reference/next.config.js/trailing-slash
【讨论】: