如何在 next.js 中省略 html 扩展名? [英] How do I omit the html extension in next.js?

查看:126
本文介绍了如何在 next.js 中省略 html 扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 next.js 构建一个静态网站,并且我希望我的 website.com/about.html 能够像这样工作:website.com/about-- 我不知道为什么它强迫我输入 .html.

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.

即使我构建了我的项目:pages/about/index.js -- 它生成一个 about.html 而不是 about/index.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.

推荐答案

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

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

这篇关于如何在 next.js 中省略 html 扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆