Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Eleventy By Example

You're reading from   Eleventy By Example Create powerful, performant websites with a static-first strategy

Arrow left icon
Product type Paperback
Published in May 2023
Publisher Packt
ISBN-13 9781804610497
Length 198 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Bryan Robinson Bryan Robinson
Author Profile Icon Bryan Robinson
Bryan Robinson
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Chapter 1: Setting Up Your Website 2. Chapter 2: Adding Data to Your 11ty Website FREE CHAPTER 3. Chapter 3: Deploying to a Static Site Host 4. Chapter 4: Building a Blog with Collections 5. Chapter 5: Creating Custom Shortcodes to Add Mixed Media to Markdown 6. Chapter 6: Building a Photography Site with the 11ty Image Plugin 7. Chapter 7: Building a Podcast Website with 11ty Plugins and Custom Outputs 8. Chapter 8: Creating a Static-Site Search with 11ty Serverless and Algolia 9. Chapter 9: Integrating 11ty with a Headless CMS 10. Chapter 10: Creating Custom 11ty Plugins 11. Index 12. Other Books You May Enjoy

Creating a collection with directory data and Markdown

To start, let’s create a new directory in our src folder named posts. This will be the directory that houses all the blog posts for our blog. Once that directory is created, add two Markdown files to the directory. The names of these files will, by default, be the URL for each post, so name them accordingly. For my posts, I’ll use my-first-blog-post.md and my-second-blog-post.md – creative, I know.

Inside these files, we need a little bit of frontmatter and then the content written in Markdown. All Markdown is acceptable, but keep in mind the template we’ll create will already have an <h1>, so it’s best not to have one in the content for SEO and accessibility reasons:

---
title: My First Blog Post
layout: "layouts/base.html"
tags:
    - "post"
---
## This is a headline for a blog post
This is a paragraph for a blog post.

This creates a singular...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime