static-site - 如何在 110(静态站点生成)输出中保留带有 .html 后缀的页面?
问题描述
我有一个现有的老式纯 html 静态站点,我想用 SSG 进行改造,我选择了十一。
该网站的结构是这样的:
+ index.html
+ somepage.html
+ otherpage.html
如https://www.11ty.dev/docs/permalinks/#cool-uris-dont-change所述,十一将创建:
+ index.html
+ somepage/index.html
+ otherpage/index.html
我不想更改我已经拥有的(不)酷的 URI :-)
我知道我可以在服务器上添加一个 .htaccess 重写来重写 URL。
但是是否可以配置 110 使其保持旧站点的确切结构?我想是的,但在文档中没有找到。
解决方案
pdehaan 在https://github.com/11ty/eleventy/issues/913上回答了这个问题,并提供了指向https://github.com/pdehaan/11ty-dynamic-permalink-test/的链接
.eleventy.js
module.exports = (eleventyConfig) => {
return {
dir: {
input: "src",
output: "www"
}
};
};
src/pages/pages.11tydata.json
{
"permalink": "{{ page.fileSlug }}.html"
}
这是源目录结构
src/
└── pages/
├── index.html
├── otherpage.html
├── pages.11tydata.json
└── somepage.html
推荐阅读
- handlebars.js - jsreport 车把引擎和 xlsx 配方:如何用颜色填充单元格
- python - IndexError:未提供参数时列表索引超出范围
- html - 如何根据里面的内容为盒子的高度设置动画?
- python - 烧瓶 API。加载状态响应
- php - 使用 PHP 将 .docx 文件发送到浏览器
- sikuli-script - Sikuli IDE 错误 - javax.script.ScriptException " 未在 nashorn:mozilla_compat.js 中第 69 行定义
- sql - 每月结束的数据准备 - 超过 12 个月
- r - R - 将 DFM 转换为 LSA,然后计算余弦相似度:Error inherits(x, "Matrix") is not TRUE
- google-cloud-logging - Google Cloud Logging 身份验证/权限
- r - 患者在 R 中表现良好的编程概率