eleventy setup

Eleventy setup that:
- treats site/ as the project source,
- outputs to public/ (what Netlify will serve),
- uses a front-matter flag publish: true to select the subset for the published site, and
- passthroughs site/style.css and any assets.

my-notes/
  site/
    style.css
    notes/
      note1.md
      note2.md
      ...
    layouts/
      base.njk
      note.njk
      index.njk
  .eleventy.js
  package.json
  netlify.toml
  README.md

All markdown files live under site/notes/. Mark the files you want Netlify to publish with publish: true in their front matter.

.eleventy.js (drop In Repo root)

module.exports = function(eleventyConfig) {
  // Passthrough static assets
  eleventyConfig.addPassthroughCopy({"site/style.css": "style.css"});
  eleventyConfig.addPassthroughCopy({"site/assets": "assets"}); // optional

  // Collection: only items with publish: true
  eleventyConfig.addCollection("published", function(collectionApi) {
    return collectionApi.getFilteredByGlob("site/notes/**/*.md")
      .filter(item => {
        const fm = item.data || {};
        return fm.publish === true;
      })
      .sort((a,b) => {
        // optional order: by date desc if provided, otherwise filename
        const da = a.date || new Date(a.inputPath);
        const db = b.date || new Date(b.inputPath);
        return db - da;
      });
  });

  return {
    dir: {
      input: "site",
      includes: "layouts",
      data: "_data",    // optional, keep default patterns
      output: "public"
    },
    markdownTemplateEngine: "njk",
    htmlTemplateEngine: "njk",
    passthroughFileCopy: true
  };
};

package.json (minimal; Run Npm Init -y then Replace or merge)

{
  "name": "my-notes",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "npx @11ty/eleventy --serve",
    "build": "npx @11ty/eleventy --quiet",
    "clean": "rimraf public"
  },
  "devDependencies": {
    "@11ty/eleventy": "^2.0.0",
    "rimraf": "^5.0.0"
  }
}

Install with:

npm install

netlify.toml


[build]
  command = "npm run build"
  publish = "public"

[dev]
command = "npm run dev"

Netlify will run npm run build and publish the public/ folder.

Example Note front Matter (site/notes/note1.md)

---
title: "Short title for note 1"
date: 2025-09-18
publish: true   # set to true to include in the public subset
---

# Heading

Content...

Set publish: false or omit the key to keep a file private on your home server.

βΈ»

Minimal Layout Files

site/layouts/base.njk

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>{% if title %}{{ title }} β€” Notes{% else %}Notes{% endif %}</title>
  <link rel="stylesheet" href="/style.css">
</head>
<body>
  <main>
    {{ content | safe }}
  </main>
</body>
</html>

site/layouts/note.njk

---
layout: base.njk
---
<article>
  <h1>{{ title }}</h1>
  <time datetime="{{ date }}">{{ date | date("yyyy-LL-dd") }}</time>
  <section>
    {{ content | safe }}
  </section>
</article>

site/layouts/index.njk (index For Published subset)

---
layout: base.njk
---
<h1>Notes</h1>
<ul>
  {% for item in collections.published %}
    <li><a href="{{ item.url }}">{{ item.data.title or item.fileSlug }}</a></li>
  {% endfor %}
</ul>

Eleventy will use index.njk at site/index.njk (or create site/index.md with layout: index.njk) to produce public/index.html listing only files with publish: true.

Local Development / home Server

If you want to serve the full set locally (including unpublished files), keep a simple copy of site/ and serve it directly (e.g. point your server to site/), while using Eleventy to produce the pared public/ for GitHub/Netlify.

Notes & Small Gotchas