Eleventy Static Site Tutorial: Build a Fast Shop Site

Quick answer
Eleventy, also called 11ty, is a static site generator for Node.js: it turns templates and a data file into plain HTML at build time, with no server and no database to run. You write pages in Nunjucks, Liquid, or Markdown, and Eleventy writes a finished site into a folder called _site. This post builds a three page shop site from four real orders and shows the first error most beginners hit.
A small shop in Karachi takes orders over the phone and writes each one in a paper notebook. The owner wants a simple website: a home page, an orders list, and a short about page, and nothing else. There is no login, no search box, and no checkout, so a full web framework would be overkill. A static site fits: build the pages once, host the folder anywhere, and it loads fast on a slow connection. Eleventy fits because it stays out of the way and keeps the order data in one small file.
What I would check before using it
My first check is how often the pages change. Eleventy rebuilds the whole site whenever the data changes, so it suits pages that update a few times a day, like a shop order list. A site that changes every minute, such as a live stock ticker, needs a server instead. The Hugo Explained: Blazing-Fast Static Sites From Go post makes the same point about build time sites, and the Astro Explained: Websites That Ship Less JavaScript post shows another generator that starts from the same idea.
My second check is who will edit the pages. Eleventy lets you write content in Markdown, so a person who never touches code can still edit a page. The layout lives in a separate template file, which keeps words and design apart.
My third check is the data. Eleventy reads JSON and JavaScript data files straight into templates, which is exactly what the orders list needs. If the data lived behind an API that needed a login, a build time fetch would be awkward, and a server rendered app would fit better.
My fourth check is JavaScript. Eleventy ships zero JavaScript by default, so pages load fast on a slow mobile connection. That is a strength for a simple site, and a weakness if the site needs interactive widgets.
My verdict, as judgement: use Eleventy for a small site with a few pages and data in a file, especially when speed matters and nobody needs a dashboard. Keep a framework for anything interactive or user specific. The recommendation flips if the site needs login, live data, or heavy interaction, or if the team has no Node.js experience at all.
Four orders, three pages, and one missing layout
Four orders belong to one small shop: Ayesha in Karachi, Rs 12,400; Bilal in Lahore, Rs 7,800; Hina in Karachi, Rs 9,600; Usman in Islamabad, Rs 15,200.
First, install Eleventy. It needs Node.js, and the install here added 127 packages.
$ npm install @11ty/eleventy
added 127 packages in 10s
The site has five source files: the data file holds the orders, the layout file is the shared page shell, and each page names that layout.
// _data/orders.js: the shop orders for the Eleventy demo site.
module.exports = [
{ id: 101, customer: "Ayesha", city: "Karachi", items: "kurta, dupatta", total: 12400 },
{ id: 102, customer: "Bilal", city: "Lahore", items: "sneakers", total: 7800 },
{ id: 103, customer: "Hina", city: "Karachi", items: "handbag, wallet", total: 9600 },
{ id: 104, customer: "Usman", city: "Islamabad", items: "jacket, shalwar kameez", total: 15200 }
];
<!-- _includes/layouts/base.njk: the shared page shell. -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ title }}</title>
</head>
<body>
<header>
<h1>Karachi Corner Shop</h1>
<nav><a href="/">Home</a> | <a href="/orders/">Orders</a> | <a href="/about/">About</a></nav>
</header>
<main>
{{ content | safe }}
</main>
<footer>
<p>Built with Eleventy. Four orders on file, grand total Rs 45000.</p>
</footer>
</body>
</html>
The orders page loops over the data file with a Nunjucks for loop, so adding a fifth order later means editing one file, not three pages. The Gatsby Explained: React Sites With Data From Anywhere post builds a similar data driven page with React.
---
layout: layouts/base.njk
title: Orders
---
<h2>Orders</h2>
<ul>
{% for order in orders %}
<li>Order {{ order.id }}: {{ order.customer }} ({{ order.city }}) - {{ order.items }} - Rs {{ order.total }}</li>
{% endfor %}
</ul>
<p>Grand total: Rs 45000</p>
The home page is a short Nunjucks template and the about page is plain Markdown, which shows Eleventy mixes template languages in one site without extra setup.
The thing that went wrong was the first build: the home page named a layout file that did not exist, layouts/site.njk, while the real file was called layouts/base.njk. Eleventy stopped the whole build, wrote zero files, and named the missing file in the error. The fix was one line, change the front matter to layout: layouts/base.njk. The next build wrote all three pages in 0.18 seconds.
$ npx @11ty/eleventy
[11ty] Problem writing Eleventy templates:
[11ty] 1. Problem creating an Eleventy Layout for the "./index.njk" template file. (via EleventyBaseError)
[11ty] 2. You're trying to use a layout that does not exist: _includes/layouts/site.njk (via `layout: layouts/site.njk`)
[11ty] Wrote 0 files in 0.14 seconds (v3.1.8)
$ npx @11ty/eleventy
[11ty] Writing ./_site/index.html from ./index.njk
[11ty] Writing ./_site/orders/index.html from ./orders.njk
[11ty] Writing ./_site/about/index.html from ./about.md (liquid)
[11ty] Wrote 3 files in 0.18 seconds (v3.1.8)
The generated orders page holds all four orders, exactly as the data file lists them, and the numbers check out: Karachi Rs 12,400 plus Rs 9,600 is Rs 22,000, and the four orders add to Rs 45,000. A local static server confirmed the site loads: all three pages returned HTTP 200.
$ python3 -m http.server 8811
$ curl -s -o /dev/null -w "home: HTTP %{http_code}\n" http://localhost:8811/
home: HTTP 200
$ curl -s http://localhost:8811/orders/ | grep -c "Order 10"
4
$ curl -s http://localhost:8811/orders/ | grep "Grand total"
<p>Grand total: Rs 45000</p>
$ curl -s -o /dev/null -w "about: HTTP %{http_code}\n" http://localhost:8811/about/
about: HTTP 200
Common mistakes and how to fix them
First, naming a layout that does not exist. The symptom is the error "You are trying to use a layout that does not exist: _includes/layouts/site.njk", the build writes 0 files, and it exits with code 1. The fix is to match the file name under _includes/layouts, or create the missing layout file.
Second, putting the data file in the wrong place. The symptom is an orders page that builds fine but renders an empty list, because Eleventy only reads data from the _data folder. The fix is to move the file into _data and name it orders.js.
Third, forgetting the safe filter in the layout. The symptom is a home page showing raw tags instead of a heading, because Nunjucks escapes HTML. The fix is to write {{ content | safe }} in the layout.
Fourth, editing the built files in _site directly. The symptom is an edit that vanishes on the next build, because Eleventy regenerates _site from the source files. The fix is to edit the source file and rebuild, and treat _site as output only.
Frequently Asked Questions
Is Eleventy the same as Hugo? No. Both build plain HTML sites, but Hugo is a single Go binary, while Eleventy runs on Node.js and lets you mix Nunjucks, Liquid, Markdown, and plain HTML in one site.
Do I need to learn Nunjucks to use Eleventy? No. A site written entirely in Markdown works, and each file names its layout in the front matter. Nunjucks only matters for loops and conditions, like the orders list in this post.
Can Eleventy fetch data from an API? Yes, at build time. A JavaScript data file can fetch from an API and Eleventy waits for the result before rendering, but the data is frozen at build time, so it only suits data that changes slowly.
What to remember
- Eleventy turns templates and a data file into plain HTML at build time, with no server to run.
- Layouts live under _includes/layouts, and a wrong name stops the build with a clear error.
- Data files go in the _data folder, and the file name becomes the variable name in templates.
- The _site folder is output only, so edit the source files and rebuild.
Where this leaves you
Eleventy earns its place the day a pile of hand written HTML pages starts repeating the same header and footer, and one data file could drive them all. The demo proved it: three pages came from five small source files, the orders list rendered all four orders with the right totals, and the one real mistake, a missing layout, failed loudly instead of publishing a broken page. Take a small site you already maintain by hand and rebuild it in Eleventy. A generator that stops on a bad layout beats a copy paste workflow that silently ships one.
Further reading
- Eleventy docs
- Eleventy getting started guide
- MDN: HTML basics
- Node.js: Introduction to Node.js
- Hugo Explained: Blazing-Fast Static Sites From Go
- Astro Explained: Websites That Ship Less JavaScript
- Gatsby Explained: React Sites With Data From Anywhere
- Next.js Explained: React, Ready for Production Apps
Waqas Shahid is a software engineer from Karachi with more than 12 years of experience, including 6+ years in engineering leadership. He writes The Practical Developer.
Comments
Join the discussionNo comments yet. Be the first to comment.





