How to Build Your Own iA Writer Templates

In my last post, I wrote about how iA Writer became my notes app. But iA Writer has always been the place where I write everything else as well: the newsletter, talks and blog posts for all my websites. And every time I hit preview, I saw … iA Writer’s default template. Nice, clean, but not my websites.

So I sat down and built my own preview templates. One for beyond tellerrand, one for marcthiele.com and one for neu•gierig. Same fonts, same colours, same headlines as on the real sites. Now I see a post the way it will look once it’s published. Before it’s published.

And the best part: if you can build a website, you can build an iA Writer template. It’s basically HTML and CSS. That’s it. ;)

The same blog post shown in three iA Writer preview templates side by side. On the left, marcthiele.com with dark grey serif headlines and orange links on white. In the middle, beyond tellerrand with light text on a dark background and a gold headline. On the right, neu•gierig with heavy brown headlines on a warm paper-coloured background.
My three templates: marcthiele.com, beyond tellerrand and neu•gierig

What a Template Actually Is

An iA Writer template is a so-called bundle. It looks like a single file in Finder, but it is really a folder ending in .iatemplate. Right-click it and choose Show Package Contents and you see what’s inside. This is my beyond tellerrand template:

beyond tellerrand.iatemplate/
  Contents/
    Info.plist
    Resources/
      document.html
      title.html
      header.html
      footer.html
      style.css
      fonts/
        LektoratDisplay_var-Upright.woff2
        LektoratDisplay_var-Oblique.woff2
        LektoratText_var-Upright.woff2
        LektoratText_var-Oblique.woff2

The only file you really need is document.html. Title page, header and footer are optional. They are only used when you export a PDF or print.

Step 1: Start with iA’s Example

You don’t have to start from zero. iA has an example template on GitHub, together with a pretty good documentation of everything a template can do. Download it, duplicate Example.iatemplate and rename it. That’s your starting point.

Step 2: Tell iA Writer Who You Are

Info.plist describes your template. It looks a bit scary if you’ve never seen a property list before, but it’s “just” XML and any text editor can open it. These are the important parts of mine:

<key>CFBundleIdentifier</key>
<string>com.beyondtellerrand.iawriter.template</string>
<key>CFBundleName</key>
<string>beyond tellerrand</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>IATemplateDocumentFile</key>
<string>document</string>
<key>IATemplateTitleFile</key>
<string>title</string>
<key>IATemplateHeaderFile</key>
<string>header</string>
<key>IATemplateHeaderHeight</key>
<integer>70</integer>
<key>IATemplateFooterFile</key>
<string>footer</string>
<key>IATemplateFooterHeight</key>
<integer>70</integer>
  • CFBundleName is the name you see in iA Writer’s template menu.
  • CFBundleIdentifier has to be unique. Use your own domain, backwards.
  • CFBundleShortVersionString is your version number. Count it up whenever you change something. Just a tip, but you might thank yourself later. ;)
  • The IATemplate…File keys point to the HTML files, without .html. Leave out header, footer or title if you don’t need them.

Step 3: The Document Page

document.html is almost embarrassingly short:

<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" media="all" href="style.css">
</head>
<body data-document>&nbsp;</body>
</html>

The most important bit that is more or less the engine of everything is data-document. iA Writer takes your Markdown, turns it into HTML and puts it right inside that element. Everything else is up to your CSS.

Step 4: Bring Your Website’s CSS

I opened the stylesheets of my websites and took what I needed: fonts, colours, headline sizes, links, lists, quotes.

First the fonts. Copy the .woff2 files into a fonts folder inside Resources and load them with relative paths:

@font-face {
  font-family: 'LektoratDisplay';
  src: url('fonts/LektoratDisplay_var-Upright.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
}

Then the colours, as custom properties, just like on the website:

:root {
  --color-black: #1C1C1C;
  --color-white: #f3f1eb;
  --color-gold: #b38f5d;
}

html {
  background-color: var(--color-black);
  color: var(--color-white);
  font-family: 'Lektorat', system-ui, sans-serif;
}

And then the details that make it feel like beyond tellerrand. The narrow Lektorat Display for headlines, gold H2s, gold list bullets and gold underlines for links:

h1, h2, h3, h4, h5, h6 {
  font-family: 'LektoratDisplay', system-ui, sans-serif;
  font-variation-settings: 'wdth' 80, 'wght' 600;
  line-height: 1.25;
  text-wrap: balance;
}

h2 { color: var(--color-gold); }
li::marker { color: var(--color-gold); }

a {
  color: inherit;
  text-decoration-color: var(--color-gold);
  text-decoration-thickness: 2px;
}

You could copy your whole website CSS, but don’t! It bloats up the file size and is not needed. Navigation, grid, footer … none of it matters here. You only need the parts that style text.

Step 5: Dark Mode or Not

When iA Writer runs in dark mode, it adds the class night-mode to the html element. So you can define a dark version of your template:

html.night-mode {
  --text: #d5d9dc;
  --background: #1f2326;
}

For beyond tellerrand that’s easy: the website is dark anyway, so the template is always dark. marcthiele.com and neu•gierig, on the other hand, don’t have a dark mode (yet). So I wanted them to stay light, always.

Removing the dark styles wasn’t enough, though. My preview still showed up dark. Only when I forced the light colours, even in night mode, did it work:

html, html.night-mode {
  color-scheme: light;
  background-color: #fff !important;
  color: #343a3e !important;
}

Not the most elegant CSS, I know. But it works. ;)

Step 6: Print and PDF

Somehow a bonus and I really rarely use printing these days, but if so, a dark template is lovely on screen, but nobody wants to print a black page. So for beyond tellerrand, I switch to white paper when printing or exporting a PDF:

@media print {
  html { background-color: #fff; color: var(--color-black); }
  h2, li::marker { color: var(--color-gold-dark); }
}

For page numbers, footer.html gets two placeholders that iA Writer fills in:

<body class="footer">
  <p><span data-page-number></span> / <span data-page-count></span></p>
</body>

The same works for the document title in the header, with data-title.

Step 7: Install and Switch

On the Mac, double-click the .iatemplate file. That’s all. In the preview, you can then switch templates via the toolbar or View › Template.

On the iPhone, put the template as a ZIP file into iCloud Drive and tap it in the Files app. It opens in iA Writer and gets installed.

Things I Learned on the Way

  • iA Writer copies the template when you install it. Changing the original file afterwards does nothing. To update a template, delete the old one under Settings › Templates, quit iA Writer completely with ⌘Q and install the new version. Otherwise the preview happily keeps showing you the old one.
  • Be careful with fonts. Fira is free, but Lektorat, Adelle and Bree are commercial fonts. Using them in my own templates is fine for me, but you should not share those templates with the fonts inside.
  • Kirby fields show up as text. My blog posts are Kirby text files, so Title:, ---- and Date: appear as normal paragraphs in the preview. The article text below looks exactly like it will on the site, though, and that’s what I care about. It would be great to convert the Kirby text like the
    tag to show the images, but well … you can’t have everything.
  • Templates aren’t remembered per document. iA Writer doesn’t switch templates per file or folder. When I jump from a beyond tellerrand post to a marcthiele.com post, I switch by hand. Two clicks. I can live with that.

Your Turn

If you write for your own website in iA Writer, give it a try. It took me one evening for three templates, and now my posts look like home and I don’t need to test it on my local server anymore.

And if you build one, I’d love to see it. Send me an email.

Leave a comment

By submitting your data, you agree that all entered data may be saved and displayed as a comment.