Skip to content

Templates

If a collection’s files share a shape, like the same headings in every book review, or tags that are nearly always set, a template saves typing it each time. New files in the collection start as a copy of it.

Create a folder called .astro-editor in the collection’s folder, the one you browse in the sidebar, and a file called template.md in it:

  • Directorysrc/content/
    • Directoryreviews/
      • Directory.astro-editor/
        • template.md
      • 2026-11-02.md
      • 2026-11-09.md

Write it as you’d write any file in the collection:

src/content/reviews/.astro-editor/template.md
---
# Fill in the rating once you've finished it
title: Book Title
pubDate: 2024-01-01
rating: 3
tags:
- books
---
## Summary
## What I thought

Astro’s loaders don’t look inside folders whose names start with a dot, so with the usual collection patterns, Starlight’s included, the template is never part of your site. Astro Editor doesn’t list it either, so you edit it in your IDE or another editor. On a Mac, Finder hides the folder too, until you press Cmd+Shift+. in Finder to show hidden files. The collection’s page in Project Settings shows the template’s path, with buttons to copy it or open it in your IDE.

A template only applies to its own collection, and only from the collection’s folder. A .astro-editor folder in a subfolder is ignored.

Command + N Control + N Command + N in the collection copies the template as written, including its comments, its body and any fields your schema doesn’t list. Then:

  • The template’s title is the placeholder title, which is selected so you can type over it.
  • The published date is today, whatever the template says.
  • Required fields the template leaves out are filled in as they are for any new file.

The file is named by the collection’s file name pattern, as usual.

A template can be template.md or template.mdx. Either way, the new file gets the collection’s new file type, so a template.md with a few headings works for an MDX collection. If you use MDX imports or components in a template for a Markdown collection, they’re copied into the Markdown file as they are, and you’ll need to change the collection’s type or the template. If the folder has both, the one matching the new file type is used.

Write relative paths in a template, like MDX imports and images, as they’ll be in a new file at the collection’s folder, not from the .astro-editor folder. Your IDE may mark them as missing while you edit the template.

The new action of the URL scheme creates a file the same way, from the template, so you can capture notes from Raycast, Shortcuts or a bookmarklet.