英文:
Failing to build eleventy blog
问题
I am trying to create a personal blog. My directory structure looks like the following:
My .eleventy.js
looks like the following:
module.exports = function (eleventyConfig) {
eleventyConfig.setTemplateFormats(["md", "html"]);
// Copy static files to output folder
eleventyConfig.addPassthroughCopy('src/images');
eleventyConfig.addPassthroughCopy('src/css');
eleventyConfig.addPassthroughCopy('src/js');
// Set input and output folders
return {
dir: {
input: '_src',
output: '_site',
includes: '_includes',
layouts: '_layouts'
}
};
};
When I build I get the following:
$ sudo npm run build
> personal_blog_eleventy@1.0.0 build
> eleventy
[11ty] Writing _site/_posts/post-1/index.html from ./_src/_posts/post-1.md (liquid)
[11ty] Writing _site/_posts/post-2/index.html from ./_src/_posts/post-2.md (liquid)
[11ty] Wrote 2 files in 0.11 seconds (v2.0.1)
However, when running eleventy --serve
I only get:
Any suggestions what I am doing wrong?
I appreciate your replies!
英文:
I am trying to create a personal blog. My directory structure looks like the following:
My .eleventy.js
looks like the following:
module.exports = function (eleventyConfig) {
eleventyConfig.setTemplateFormats(["md", "html"]);
// Copy static files to output folder
eleventyConfig.addPassthroughCopy('src/images');
eleventyConfig.addPassthroughCopy('src/css');
eleventyConfig.addPassthroughCopy('src/js');
// Set input and output folders
return {
dir: {
input: '_src',
output: '_site',
includes: '_includes',
layouts: '_layouts'
}
};
};
When I build I get the following:
$ sudo npm run build
> personal_blog_eleventy@1.0.0 build
> eleventy
[11ty] Writing _site/_posts/post-1/index.html from ./_src/_posts/post-1.md (liquid)
[11ty] Writing _site/_posts/post-2/index.html from ./_src/_posts/post-2.md (liquid)
[11ty] Wrote 2 files in 0.11 seconds (v2.0.1)
However, when running eleventy --serve
I only get:
Any suggestions what I am doing wrong?
I appreciate your replies!
答案1
得分: 1
你没有一个根目录下的 index.html
文件,所以服务器正确地表示它无法获取路由 /
。
您可以通过访问 http://localhost:8080/_posts/post-1
来确认,因为该文件确实存在。
英文:
You don't have a root index.html
file, so the server is correct in saying it cannot GET the route /
.
You can confirm by going to http://localhost:8080/_posts/post-1
as that file does exist.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论