# Announcements on sites

Two ways to tell readers something, set in `.hatch/site.json` and checked like every other setting (problems show as publish warnings). Both work on every kind of site.

```json
{
  "announcement": {
    "link": { "label": "The course reopens on December 8.", "url": "https://example.com/" },
    "text": "Join the waitlist for two free lessons."
  },
  "popup": {
    "title": "The course reopens December 8",
    "text": "Join the waitlist and get two free lessons in the meantime.",
    "button": { "label": "Join the waitlist", "url": "https://example.com/" },
    "delay": 3,
    "pages": "home"
  }
}
```

## The bar

A line across the top of every page, above the header. The link comes first, in bold, then the text.

- `text` (up to 240 characters) and `link` (`label`, `url`): either or both.
- `dismissible`: readers can close it (default `true`).
- `until`: the last day it shows, like `2026-12-31`, by the reader's own date. It hides itself after that day even if the site isn't published again, and the next publish leaves it out.
- `id`: readers who closed it keep it closed while the id stays the same. Leave it out and the id comes from the words, so changing the message shows it again.

## The popup

A small dialog that opens once per reader, `delay` seconds after the page (0 to 30, default 3), on the home page or on `"pages": "all"`. Escape, the close button, a click outside or the button closes it, and it doesn't open again on that device. It never opens on top of another dialog.

- `title` (required), `text`, `button` (`label`, `url`), `delay`, `pages`, `until`, `id`.

## How it behaves

- What a reader closed is kept in their browser (`hatch-dismissed` in local storage, the last 20 ids). Nothing is sent anywhere.
- `mode.js` reads that list in the head, so a closed bar is hidden from the first frame and never flashes back.
- The popup moves its focus to itself when it opens, has a labelled heading, and only fades in for readers who haven't asked for less motion. On phones it sits at the bottom, within thumb reach.
- Links can be web addresses, `mailto:` or paths on the site. Anything else (`javascript:`, `data:`) is dropped.
- `checkAnnouncements(bar, popup)` in `packages/publish/src/announce.ts` lists problems in plain words.

## Where the code is

`packages/publish/src/announce.ts` (reading, checking, HTML, CSS, the script), `templates.ts` (where they go on the page), `site.ts` (wiring), `mode.ts` (the closed list). Tests: `announce.test.ts`.
