Guides

Migrating from v0.1

What v0.2.0 removed and renamed, what replaces families, themes, streams and placeholders, and a v0.1 program ported step by step.

v0.2.0 is a breaking release. lttr v0.1 had one design built in: a theme, 22 modules, header and footer variants, and families that tied a sender to a stream and to footer copy. In v0.2.0 the core is an engine with no design of its own, and the design comes from a kit. The v0.1 design is now the Quiet kit, with the same components, names and aliases, so most templates port with a change to their frontmatter.

This page maps every v0.1 name to what replaces it, then ports a small v0.1 program piece by piece. Snippets labelled v0.1 show the old code, which no longer compiles. CHANGELOG.md has the full list of changes.

Map v0.1 names to v0.2

v0.1v0.2
Family, Registry, NewRegistryProfile, listed in Config.Profiles. A profile has a name, a sender and headers, and no policy.
Family.From, FromFrontmatter, SenderDomainProfile.From (leave it zero to require frontmatter from) and Profile.FromDomain
Theme, theme.Light, theme.Dark, theme.FontsKit tokens in kit.yaml: colours as { light: …, dark: … }, font stacks as strings
theme.BrandThe kit's brand var and the logo files at Config.AssetBase
The 22 modules and ir.Kind…The Quiet kit's components, with the same names and aliases (statement, k1, …)
Stream, Router, ErrSuppressed, Message.Stream, Message.FamilyRoute on Message.Profile in your application, and check suppression there
Family.Tracking, Message.TrackingYour sending service's setting, per profile. Profile.Headers can carry the header your provider reads.
Header (H1, H2, H3), Footer (F1, F2, F3, F3Internal), FooterCopy, Masthead, Banner, LegalThe kit's layout.html. Quiet picks header and footer from the profile's name.
Frontmatter family:profile:
Frontmatter footer.note, footer.about, footer.reason, footer.optout, footer.nav, legal, issueFrontmatter keys the kit declares. Quiet's are note, about, reason, optout, nav, legal and issue.
{site}, {brand}, {domain}, {region}, {address}, {about}, {prefs}, {unsubscribe}, {issue} placeholders, and lttr.VarsKit vars, which kit templates read as {{var "site"}} and Config.Vars sets, and merge tags from your own data
Config.Domain, Config.SiteURLKit vars. Quiet's are domain and site.
Config.Entities, DefaultRegion, EntityKit vars. Quiet's are address and region: build a Renderer per entity with its own Vars.
Recipient.FirstName, Region, EntityAddress, PreferencesURLFields of your data type, or kit vars. Recipient is {Address, Name, UnsubscribeURL}, and Name is the To display name.
mapboxFetch the static map from your provider yourself, host it, and pass its URL in your data
data.Money, Exact, Receipt, ReceiptLine, Fee, StockItem, Product, ToneThe same types in kits/quiet
data.USD, data.USDCode, data.EURCode, data.GBPCodequiet.USD, quiet.USDCode, quiet.EURCode, quiet.GBPCode. The other v0.1 currency constant and its constructor are gone: use your own quiet.Currency code, with Symbol for its prefix.
Compile[T](reg, name, src), MustCompileCompile[T](k, name, src), with a *kit.Kit
TemplateMeta.Family, .Stream, .ModulesTemplateMeta.Profile, .Components
Family.ForbiddenNothing built in. A test can check each template's Meta().Components.
layout and its spacing tableEach component's spacing in its component.yaml
ir.CompileCopy, ir.CompileCopyText, ir.SlotVars, ir.Ref.PlaceholderRemoved, with the placeholders
examples/quiet: Theme(), Families, Mapbox()Kit(), Profiles(), Vars(), and Set(), the nine examples as an lttr.SampleSet. Config(assetBase), Examples() and ByName() remain.

Replace families with profiles

A v0.1 family fixed the sender, the stream, the header and footer, and the footer's copy:

v0.1
// v0.1: families fixed the sender, stream, header, footer and footer copy.
var families = lttr.NewRegistry(
    lttr.Family{
        Name:   "buyer",
        From:   mail.Address{Name: "Loam", Address: "orders@loam.example"},
        Stream: lttr.Transactional,
        Header: lttr.H1,
        Footer: lttr.F2,
        Copy: lttr.FooterCopy{
            Note:    "Questions? Reply to this email.",
            About:   "your order",
            Service: "This is a service email about {about}. [Notification settings]({prefs})",
            Address: "{brand} · {address}",
        },
    },
    lttr.Family{
        Name:     "newsletter",
        From:     mail.Address{Name: "Field Notes", Address: "notes@loam.example"},
        Stream:   lttr.Marketing,
        Header:   lttr.H3,
        Masthead: "Field Notes · No. {issue}",
        Footer:   lttr.F1,
        Copy: lttr.FooterCopy{
            Reason:  "You're getting Field Notes because you subscribed on {domain}.",
            Links:   "[Unsubscribe]({unsubscribe}) · [Preferences]({prefs})",
            Address: "{brand} · {address}",
        },
        Tracking: true,
    },
)

A profile keeps only the sender and the headers. The header, the footer and their copy belong to the kit. Quiet chooses them from the profile's name, so keep the names Quiet knows: buyer gets the service footer, and newsletter the marketing footer with the nav row. The table in Choose a footer with the profile lists them all.

main.go
// profiles replace the v0.1 family registry: a name, a sender and headers.
// Quiet picks each footer from the profile name.
func profiles() []lttr.Profile {
    return []lttr.Profile{
        {Name: "buyer", From: mail.Address{Name: "Loam", Address: "orders@loam.example"}},
        {Name: "newsletter", From: mail.Address{Name: "Field Notes", Address: "notes@loam.example"}, ListUnsubscribe: true},
    }
}

ListUnsubscribe: true takes over from the marketing stream's automatic List-Unsubscribe headers: the renderer sets them from the recipient's UnsubscribeURL, which must then be https. See Profiles and config.

Move the brand into vars and tokens

The v0.1 Config carried the brand, the families and the legal entities:

v0.1
// v0.1: the Config held the domain, the site, the theme, the families
// and the entity address of each region.
r, err := lttr.NewRenderer(lttr.Config{
    Domain:        "loam.example",
    SiteURL:       "https://loam.example",
    AssetBase:     "https://loam.example/assets/email",
    Theme:         brand,
    Families:      families,
    Entities:      map[string]lttr.Entity{"Alder Valley": {Address: "12 Mill Lane, Alder Valley"}},
    DefaultRegion: "Alder Valley",
})

Now Config holds the kit, the profiles, the asset base and the var overrides. Everything the footer used to fill from placeholders is a kit var:

main.go
// vars replace Config.Domain, SiteURL, Theme.Brand and the entity address.
func vars() map[string]string {
    return map[string]string{
        "brand":   "Loam",
        "site":    "https://loam.example",
        "domain":  "loam.example",
        "help":    "https://loam.example/help",
        "prefs":   "https://loam.example/preferences",
        "address": "12 Mill Lane, Alder Valley",
        "journal": "Field Notes",
    }
}
main.go
r, err := lttr.NewRenderer(lttr.Config{
    Kit:       quiet.MustKit(),
    Profiles:  profiles(),
    AssetBase: "https://loam.example/assets/email",
    Vars:      vars(),
})

NewRenderer rejects a var the kit doesn't declare, so a typo in a key fails at startup. The Quiet kit lists Quiet's vars and where each one appears.

The v0.1 Theme has no counterpart in Config. Colours, fonts and sizes are kit tokens, fixed when the kit loads. Quiet's tokens are its own design. For your own colours, build a kit from Plain, where a colour and a font stack look like this:

tutorial/kit/kit.yaml#L19-L20
  color.accent:  { light: "#1A7F37", dark: "#3FB950" }  # was Plain's blue
  color.button:  { light: "#1A7F37", dark: "#1A7F37" }  # was Plain's blue
tutorial/kit/kit.yaml#L24-L25
  # Quote family names with spaces in single quotes: "'Helvetica Neue',Arial,sans-serif".
  font.sans: "'Helvetica Neue',Arial,sans-serif"  # was the system stack

See Build your own kit and kit.yaml.

Update the templates

Rename family: to profile:, and flatten the footer.* keys into the keys the kit declares:

v0.1
---
template: order.dispatched
family: buyer
subject: "Order {{order_id}} is on its way"
preheader: "Arriving {{arrives}}."
footer:
  note: Questions about your order? Reply to this email.
---
templates/order-dispatched.md
---
template: order.dispatched
profile: buyer
subject: "Order {{order_id}} is on its way"
preheader: "Arriving {{arrives}}."
note: Questions about your order? Reply to this email.
---

The body usually needs no change. The module names and their handoff aliases are Quiet's component names, with the same attributes. Look out for three things:

  • Recipient fields. {{first_name}} used to fall back to Recipient.FirstName, which is gone. Put the field in your data type, or use {{name}}, the recipient's display name.
  • Empty optional URLs. An optional url attribute whose merge tag evaluates to "" is unset only with an explicit empty fallback: ::map{src="{{map_url |}}"}. Without the |, an empty value is a render error: no value for {{map_url}}.
  • Placeholders in copy. {site} and the other placeholders are plain text now. In kit templates, read {{var "site"}}. In a Markdown template, use a merge tag from your data.

Strikethrough, link titles and images in prose are now parsed, and each component allows or rejects them. Raw HTML is still an error: HTML your application renders itself reaches a component from Go, through an html attribute and an lttr.TrustedHTML field (see Pass trusted HTML). Every column in an error message is 1-based, and an unknown name ends with the closest known one, as in unknown name "otp_cod" (did you mean otp_code?).

Compile against the kit

Compile and MustCompile take the kit where they took the registry:

v0.1
// v0.1: templates compiled against the family registry.
var orderDispatched = lttr.MustCompile[OrderDispatched](families, "order.dispatched", []byte(orderDispatchedSrc))
main.go
var orderDispatched = lttr.MustCompile[OrderDispatched](quiet.MustKit(), "order.dispatched", []byte(orderDispatchedSrc))

Compile against the same *kit.Kit the renderer uses. quiet.MustKit() returns the same one on every call.

The typed values the modules bound are in kits/quiet now, with the same fields. quiet.Money adds Symbol, an optional display prefix. Only the USD, EUR and GBP constants carried over; the other v0.1 currency constant is gone. For any other currency, set your own quiet.Currency code and a Symbol: without a Symbol, an unknown code prints before the amount (ABC 1.50).

v0.1
// v0.1: money and receipts lived in the data package.
Subtotal: data.Money{Minor: 4297, Currency: data.USDCode},
main.go
Subtotal: quiet.Money{Minor: 4297, Currency: quiet.USDCode, Symbol: "$"},

TemplateMeta names the profile and the components: Meta().Profile and Meta().Components replace Family, Stream and Modules.

Route messages yourself

The v0.1 Router picked a Sender by the family's stream and checked suppression and the internal allow-list:

v0.1
// v0.1: the Router sent each message through the Sender for its stream.
router := &lttr.Router{
    Streams: map[lttr.Stream]lttr.Sender{
        lttr.Transactional: transactional,
        lttr.Marketing:     marketing,
    },
    Suppressed: func(ctx context.Context, s lttr.Stream, addr string) (bool, error) {
        return s == lttr.Marketing && unsubscribed(addr), nil
    },
}
err = router.Send(ctx, m)

Streams are gone. Every Message carries the name of its profile, so route on that:

main.go
// send replaces the v0.1 Router: route on Message.Profile, and check
// suppression yourself.
func send(ctx context.Context, m *lttr.Message, transactional, marketing lttr.Sender, suppressed func(string) bool) error {
    switch m.Profile {
    case "newsletter":
        if suppressed(m.To.Address) {
            return nil
        }
        return marketing.Send(ctx, m)
    default:
        return transactional.Send(ctx, m)
    }
}

lttr.SMTP and the Sender interface are unchanged. See SMTP.

Host your own maps

The mapbox package and examples/quiet's Mapbox() are gone. lttr no longer talks to a map provider. Request the static map image from your provider when you send, upload it to your own CDN, and pass the CDN URL in your data. Quiet's map component shows it, or its map-coloured ground when the URL is empty:

examples/quiet/templates/06-courier-job.md
::map{src="{{map_url |}}" pickup="{{pickup_area}}" dropoff="{{dropoff_area}}"}
::

Keep the provider's API URL out of the email: it carries your access token.

Run the ported program

The pieces above in one file. It renders the order email for Ana and sends it through a stand-in Sender that prints the message:

main.go
package main

import (
    "context"
    "fmt"
    "log"
    "net/mail"

    "github.com/sulv-io/lttr"
    "github.com/sulv-io/lttr/kits/quiet"
)

// profiles replace the v0.1 family registry: a name, a sender and headers.
// Quiet picks each footer from the profile name.
func profiles() []lttr.Profile {
    return []lttr.Profile{
        {Name: "buyer", From: mail.Address{Name: "Loam", Address: "orders@loam.example"}},
        {Name: "newsletter", From: mail.Address{Name: "Field Notes", Address: "notes@loam.example"}, ListUnsubscribe: true},
    }
}

// vars replace Config.Domain, SiteURL, Theme.Brand and the entity address.
func vars() map[string]string {
    return map[string]string{
        "brand":   "Loam",
        "site":    "https://loam.example",
        "domain":  "loam.example",
        "help":    "https://loam.example/help",
        "prefs":   "https://loam.example/preferences",
        "address": "12 Mill Lane, Alder Valley",
        "journal": "Field Notes",
    }
}

// OrderDispatched was the v0.1 data type. data.Money is quiet.Money now,
// and the recipient's first name, no longer a Recipient field, is data.
type OrderDispatched struct {
    FirstName string      `json:"first_name"`
    OrderID   string      `json:"order_id"`
    Arrives   string      `json:"arrives"`
    Subtotal  quiet.Money `json:"subtotal"`
    Delivery  quiet.Money `json:"delivery"`
    TrackURL  string      `json:"track_url"`
}

const orderDispatchedSrc = `---
template: order.dispatched
profile: buyer
subject: "Order {{order_id}} is on its way"
preheader: "Arriving {{arrives}}."
note: Questions about your order? Reply to this email.
---

::statement{eyebrow="Order {{order_id}}"}
# Your box is on its way.

Hi {{first_name | there}}, it should arrive {{arrives}}.

:button[Track delivery]{href="{{track_url}}"}
::

::breakdown
| Produce | {{subtotal}} |
| --- | ---: |
| Delivery | {{delivery}} |
::

::signoff
::
`

var orderDispatched = lttr.MustCompile[OrderDispatched](quiet.MustKit(), "order.dispatched", []byte(orderDispatchedSrc))

// send replaces the v0.1 Router: route on Message.Profile, and check
// suppression yourself.
func send(ctx context.Context, m *lttr.Message, transactional, marketing lttr.Sender, suppressed func(string) bool) error {
    switch m.Profile {
    case "newsletter":
        if suppressed(m.To.Address) {
            return nil
        }
        return marketing.Send(ctx, m)
    default:
        return transactional.Send(ctx, m)
    }
}

// printer stands in for an lttr.SMTP sender.
type printer string

func (p printer) Send(_ context.Context, m *lttr.Message) error {
    fmt.Printf("%s: %s → %s: %s\n\n%s", p, m.From.Address, m.To.Address, m.Subject, m.Text)
    return nil
}

func main() {
    r, err := lttr.NewRenderer(lttr.Config{
        Kit:       quiet.MustKit(),
        Profiles:  profiles(),
        AssetBase: "https://loam.example/assets/email",
        Vars:      vars(),
    })
    if err != nil {
        log.Fatal(err)
    }
    m, err := orderDispatched.Render(r, lttr.Recipient{Address: "ana@example.com", Name: "Ana Reyes"}, OrderDispatched{
        FirstName: "Ana",
        OrderID:   "LM-3107",
        Arrives:   "on Thursday",
        Subtotal:  quiet.Money{Minor: 4297, Currency: quiet.USDCode, Symbol: "$"},
        Delivery:  quiet.Money{Minor: 295, Currency: quiet.USDCode, Symbol: "$"},
        TrackURL:  "https://loam.example/orders/LM-3107",
    })
    if err != nil {
        log.Fatal(err)
    }
    noOne := func(string) bool { return false }
    if err := send(context.Background(), m, printer("transactional"), printer("marketing"), noOne); err != nil {
        log.Fatal(err)
    }
}
Output
transactional: orders@loam.example → ana@example.com: Order LM-3107 is on its way

LOAM

ORDER LM-3107

Your box is on its way.

Hi Ana, it should arrive on Thursday.

Track delivery:
https://loam.example/orders/LM-3107

Produce ......................... $42.97
Delivery ........................ $2.95

Thanks,
The Loam team

Questions about your order? Reply to this email.

--
Loam · 12 Mill Lane, Alder Valley
Notification settings: https://loam.example/preferences

The footer's first line is the template's note. The rest comes from Quiet's service footer for the buyer profile and the brand, prefs and address vars.

Update tools and tests

  • CLI. lttr lint, tags, render, preview and serve take -kit quiet|plain|<dir>, with quiet the default. lttr kit init starts a kit from Plain, and lttr kit check loads a kit, renders its samples and lints the HTML. See CLI.
  • Preview manifest. manifest.json drops family and stream and adds profile. modules now lists the top-level components.
  • Lint. The structural HTML lint is the public package github.com/sulv-io/lttr/lint: lint.Lint for one document, and lint.Check for every sample of an lttr.SampleSet. It requires the color-scheme meta only for kits with dark: true.
  • Goldens. lint.Golden compares each sample of a set with <dir>/<template name>.html and .txt. Quiet's goldens dropped their number prefix: testdata/golden/01-order.out_for_delivery.html is testdata/golden/order.out_for_delivery.html, with the same bytes. examples/quiet exposes its nine templates as Set(). See Goldens and testing.
  • Version. lttr.Version is "v0.2.0". See Releasing.
Copyright © 2026