【发布时间】:2020-12-18 11:15:08
【问题描述】:
Eleventy 不会将 html 后缀添加到从嵌套 index.md 文件生成的索引文件中。
例如,这是一个包含我的源内容的示例目录结构...
|
+- /src (input dir)
|
+- post
| |
| +- my-cool-post
| |
| +- /images
| |
| +- index.md
|
+- index.md
|
+- about.md
当我运行命令npx eleventy 时,我得到以下输出...
|
+- /public (output dir)
|
+- post
| |
| +- my-cool-post
| |
| +- /images
| |
| +- index <---- NOTE there is no ".html" suffix on this file
|
+- index.html <----- this file is ok however
|
+- about.html <----- and so is this file
这就是我的.eleventy.js 配置文件设置..
// Data Extensions
const yaml = require("js-yaml");
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("_assets");
eleventyConfig.addWatchTarget("./src/_sass/");
eleventyConfig.addDataExtension("yaml", contents => yaml.safeLoad(contents));
eleventyConfig.setTemplateFormats([
"md",
"css",
"jpg",
"png",
"webp",
"svg",
"html"
]);
return {
jsDataFileSuffix: ".11ty",
dataTemplateEngine: "njk",
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
passthroughFileCopy: true,
dir: {
input: "src",
data: "_data",
includes: "_includes",
layouts: "_layouts",
output: "public"
}
}
}
如果没有*.html 后缀,url http://../post/my-cool-post 会返回 404 错误。如果我手动添加*.html 后缀,那么它可以工作。
知道我的设置有什么问题吗?
【问题讨论】: