Build a Blog from Scratch with Eleventy: "Demo"
Watch > "6 minutes to Build a Blog from Scratch."
Create index.html
Emmet: html:5
npx @11ty/eleventy --serve
Create posts/
Create posts/post-1.md
Create _includes/layout.html
Emmet: html:5
Create posts/posts.json
{
"layout": "layout.html",
"tags": "post"
}
Add to index.html
:
## Blog Posts
{% for post in collections.post %}
{{ post.data.title }}
{% endfor %}
Modify previous for
loop:
<ul>
{% for post in collections.post %}
<li><a href="{{ post.url }}">{{ post.data.title }}</a></li>
{% endfor %}
</ul>
[build]
# Directory (relative to root of your repo) that contains the deploy-ready
# HTML files and assets generated by the build. If a base directory has
# been specified, include it in the publish directory path.
publish = "_site"
# Default build command.
command = "npm run build"
Create a repo and push project to Github (instructions outside the scope of these steps).
- Create a Netlify account, use GitHub login for fastest deply
- Select "Create from Git"
- Link to Github and select your repo
- If you run Eleventy locally you can drag your _site folder to drop.netlify.com to upload it without using git.
- Netlify will recognize the values in
netlify.toml
and you can deploy! 🎉