@nera-static/mcp 1.2.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -206,8 +206,23 @@ Source: https://nera.js.org/docs/plugins.html
206
206
 
207
207
  ## Installing
208
208
 
209
+ ```bash
210
+ npx nera add navigation
211
+ ```
212
+
213
+ `nera add` installs `@nera-static/plugin-navigation`, copies its default
214
+ `config/navigation.yaml` into your site when you have none, and publishes its
215
+ templates. It needs `@nera-static/nera` 1.26.0 or later (on an older site, run
216
+ `npx nera update` first); the [CLI reference](https://nera.js.org/docs/cli.html#adding-a-plugin)
217
+ has the details.
218
+
219
+ The manual way does the same in steps: install the package, copy its
220
+ `config/<name>.yaml` from `node_modules/@nera-static/plugin-<name>/config/`
221
+ into your `config/`, and run its publish command when it ships templates:
222
+
209
223
  ```bash
210
224
  npm install @nera-static/plugin-navigation
225
+ npx nera-navigation
211
226
  ```
212
227
 
213
228
  Any dependency whose name starts with `@nera-static/plugin-` is discovered and
@@ -256,8 +271,10 @@ on a name clash. Invalid entries are skipped with a warning.
256
271
  ## Config lives in your project
257
272
 
258
273
  Every plugin reads `config/<name>.yaml` from **your** site, not from the package.
259
- The YAML shipped inside the package is documentation; copy it into your `config/`
260
- and edit. Missing keys fall back to sensible defaults.
274
+ The YAML shipped inside the package is a documented starting point:
275
+ `nera add` copies it into your `config/` when you have none, after a manual
276
+ install you copy it yourself, and then you edit it. Missing keys fall back to
277
+ sensible defaults.
261
278
 
262
279
  ## Ordering
263
280
 
@@ -267,14 +284,16 @@ last so it indexes the final page data.
267
284
 
268
285
  ## Templates
269
286
 
270
- Plugins that ship views expose a publish command:
287
+ Plugins that ship views expose a publish command, which `nera add` runs for
288
+ you:
271
289
 
272
290
  ```bash
273
291
  npx nera-navigation # copies templates into theme/views/vendor/plugin-navigation/
274
292
  ```
275
293
 
276
294
  Then `include` them from your layouts. Publishing **skips if the folder already
277
- exists** — delete it (or pass `--force`) to pull in template updates.
295
+ exists**, also when `nera add` runs again — run the publish command with
296
+ `--force` (or delete the folder) to pull in template updates.
278
297
 
279
298
  # Deployment
280
299
 
@@ -365,6 +384,7 @@ with `npx`, e.g. `npx nera validate`. The scaffold also wires `build`, `dev` and
365
384
  | `nera build` | Build `pages/` → `public/`; with `--check`, check the result too |
366
385
  | `nera dev` | Build + live-reload preview on `:3000` |
367
386
  | `nera serve` | Serve `public/` without rebuilding |
387
+ | `nera add <plugin>` | Add an official plugin: install it, copy its default config and publish its templates |
368
388
  | `nera update` | Update the site's Nera packages (`npm update`) and raise their `^` ranges in `package.json` to the installed versions, then create or refresh `AGENTS.md` and `CLAUDE.md` |
369
389
  | `nera validate` | Check layouts, includes and YAML before publishing |
370
390
  | `nera check` | Check the built `public/` for accessibility, privacy and legal-notice problems |
@@ -412,6 +432,47 @@ Netlify secrets). A custom domain still points at the old host until you run
412
432
  with `--domain <host>` and change its DNS records. `--json` reports the old
413
433
  host as `movedFrom`.
414
434
 
435
+ ### Adding a plugin
436
+
437
+ `nera add <plugin>` adds one official plugin to the site. It needs
438
+ `@nera-static/nera` 1.26.0 or later; on an older site, run `npx nera update`
439
+ first.
440
+
441
+ ```bash
442
+ npx nera add sitemap
443
+ ```
444
+
445
+ It takes one plugin per call, written as `<name>`, `plugin-<name>` or
446
+ `@nera-static/plugin-<name>`, and:
447
+
448
+ 1. runs `npm install @nera-static/plugin-<name>`;
449
+ 2. copies the plugin's default `config/<name>.yaml` into the site's `config/`
450
+ when the site has none. An existing file is kept as it is. The summary
451
+ says which: `copied`, `kept`, or `none` when the plugin ships no default;
452
+ 3. runs the plugin's [publish command](#plugin-publish-commands) when it ships
453
+ templates, which copies them into `theme/views/vendor/plugin-<name>/`.
454
+
455
+ Before npm runs, `nera add` refuses another scope, a version (`sitemap@1`), a
456
+ path and `plugin-utils` (a library, not a plugin), and it refuses a folder
457
+ that is not a Nera site. In an older cloned site, run `nera update --migrate`
458
+ first. Running it again for a plugin you already added keeps your config file
459
+ and your published templates.
460
+
461
+ With `--json` it prints one object on stdout; the output of npm and of the
462
+ publish command goes to stderr:
463
+
464
+ ```json
465
+ {
466
+ "ok": true,
467
+ "plugin": "@nera-static/plugin-sitemap",
468
+ "config": { "file": "config/sitemap.yaml", "status": "copied" },
469
+ "templates": "none"
470
+ }
471
+ ```
472
+
473
+ `status` is `copied`, `kept` or `none`, and `templates` is `published` or
474
+ `none`. A failure prints `{ "ok": false, "error": "…" }`.
475
+
415
476
  ### Starter kits
416
477
 
417
478
  A starter kit is a whole ready-to-edit site: sample pages, config, optional
@@ -614,8 +675,11 @@ untouched.
614
675
 
615
676
  ## Plugin publish commands
616
677
 
617
- Each template-shipping plugin exposes a bin to copy its Pug into
618
- `theme/views/vendor/`, e.g.:
678
+ Each template-shipping plugin exposes a bin that copies its Pug into
679
+ `theme/views/vendor/plugin-<name>/`. `nera add` runs it for you. Run it
680
+ yourself after a plain `npm install`, or to pull in template updates:
681
+ publishing skips a folder that already exists, and `--force` overwrites it,
682
+ discarding your edits to the published copies. `nera add` has no `--force`.
619
683
 
620
684
  ```bash
621
685
  npx nera-navigation
@@ -685,7 +749,66 @@ Open the site's folder in the assistant — the folder with `package.json` and
685
749
  `AGENTS.md` convention read it too.
686
750
  - **Chat assistants without access to your files** (claude.ai, ChatGPT and the
687
751
  like) never see `AGENTS.md`. Give them Nera's docs in the prompt instead —
688
- see the next section.
752
+ see [Docs for AI](#docs-for-ai).
753
+
754
+ Claude Desktop, Claude Code, Cursor and Codex can also work through the Nera
755
+ MCP server, which creates, builds, checks and publishes sites for them — see
756
+ the next section.
757
+
758
+ ## The Nera MCP server
759
+
760
+ [`@nera-static/mcp`](https://github.com/seebaermichi/nera-mcp) is a local
761
+ [MCP](https://modelcontextprotocol.io) server. It lets an assistant create,
762
+ edit, build, validate, preview and publish Nera sites in one folder on your
763
+ computer — your **Sites folder** — and nowhere else.
764
+
765
+ ### Claude Desktop extension
766
+
767
+ The easiest way, and no Node.js needed: Claude Desktop runs the server on the
768
+ Node it ships.
769
+
770
+ 1. Download `nera-mcp-<version>.mcpb` from the
771
+ [latest release](https://github.com/seebaermichi/nera-mcp/releases/latest).
772
+ 2. Double-click it and choose **Install** in Claude Desktop.
773
+ 3. Pick your **Sites folder** when Claude Desktop asks for it: the folder your
774
+ sites live in.
775
+
776
+ The extension runs on macOS and Windows. To update, install the `.mcpb` of a
777
+ newer release.
778
+
779
+ ### Claude Code plugin
780
+
781
+ The plugin brings the server and the Nera skill in one install:
782
+
783
+ ```bash
784
+ claude plugin marketplace add seebaermichi/nera-mcp
785
+ claude plugin install nera@nera
786
+ ```
787
+
788
+ or, inside Claude Code 2.1.275 or later, in one step:
789
+
790
+ ```text
791
+ /plugin install nera --marketplace seebaermichi/nera-mcp
792
+ ```
793
+
794
+ Claude Code asks for your **Sites folder** when the plugin is enabled. The
795
+ plugin starts the server with `npx`, so it needs Node.js 22.12 or later
796
+ (`node --version`).
797
+
798
+ ### Other clients
799
+
800
+ Cursor, Codex and other MCP clients add the server to their configuration by
801
+ hand, which also needs Node.js 22.12 or later. The commands and configuration
802
+ files are in the README, under
803
+ [Manual configuration](https://github.com/seebaermichi/nera-mcp#manual-configuration).
804
+
805
+ ### What the assistant can do
806
+
807
+ With the server, the assistant lists the starter kits, themes and plugins,
808
+ creates a site, reads and writes its pages and files, adds plugins, builds,
809
+ validates, starts a preview and publishes to GitHub Pages or Netlify — with the
810
+ same results as you get in a terminal. The full list is in the README, under
811
+ [Tools](https://github.com/seebaermichi/nera-mcp#tools).
689
812
 
690
813
  ## Docs for AI
691
814
 
@@ -727,8 +850,8 @@ Add a page:
727
850
 
728
851
  ```text
729
852
  Add an "About us" page at pages/about.md with the same layout as
730
- pages/index.md, and link it from the menu (add
731
- @nera-static/plugin-navigation if the site has no menu yet). Then run
853
+ pages/index.md, and link it from the menu (if the site has no menu yet, add
854
+ @nera-static/plugin-navigation with npx nera add navigation). Then run
732
855
  npx nera validate and npx nera build --check and fix what they report.
733
856
  ```
734
857
 
@@ -736,9 +859,9 @@ Add a contact form with the plugin:
736
859
 
737
860
  ```text
738
861
  Add a contact form to the contact page with @nera-static/plugin-contact-form.
739
- Install it, copy its template with its command, include it in the page
740
- template and set my address in config/contact-form.yaml. Do not write a form
741
- by hand.
862
+ Add it with npx nera add contact-form, include its template in the page
863
+ template and set my address as recipient in the config/contact-form.yaml it
864
+ copies. Do not write a form by hand.
742
865
  ```
743
866
 
744
867
  Add a second language:
@@ -766,9 +889,8 @@ with the files I need to create and their content.
766
889
 
767
890
  ## What's planned
768
891
 
769
- Planned, not available yet: an **MCP server** for Nera — a local one for
770
- Claude Desktop, Claude Code and Cursor, and a hosted connector for claude.ai
771
- and ChatGPT that works on your GitHub repository.
892
+ Planned, not available yet: a **hosted connector** for claude.ai and ChatGPT
893
+ that works on your GitHub repository, with no local install.
772
894
 
773
895
  # Build a blog with Nera
774
896
 
@@ -841,30 +963,32 @@ build server, say — is the same for every file, so the order would be arbitrar
841
963
  ## 3. List the posts on the home page
842
964
 
843
965
  `@nera-static/plugin-simple-page-list` collects the pages of a folder into a
844
- sorted list. Install it and publish its template:
966
+ sorted list. Add it:
845
967
 
846
968
  ```bash
847
- npm install @nera-static/plugin-simple-page-list
848
- npx nera-simple-page-list
969
+ npx nera add simple-page-list
849
970
  ```
850
971
 
851
- Nera picks up the plugin from your `package.json` on its own. The second command
852
- copies the template to
972
+ `nera add` installs the package, which Nera then picks up from your
973
+ `package.json` on its own. It also copies the plugin's default
974
+ `config/simple-page-list.yaml` and publishes its template to
853
975
  `theme/views/vendor/plugin-simple-page-list/simple-page-list.pug`.
854
976
 
855
- Tell the plugin which folder to list and how to sort it. Create
856
- `config/simple-page-list.yaml`:
977
+ The copied config already lists the posts folder, newest first. Without its
978
+ comments it reads:
857
979
 
858
- ```yaml
859
- page_path: /posts
980
+ ```yaml:config/simple-page-list.yaml
981
+ page_paths:
982
+ - /posts
860
983
  more_link_text: Read more
861
984
  sortBy: date
862
985
  sortOrder: descending
863
986
  ```
864
987
 
865
- `page_path` gives you one flat list in `app.pageList`, which is all a blog with
866
- one section needs. `sortBy: date` reads a post's `date` from the frontmatter and
867
- falls back to `createdAt`, so your posts sort by the dates you just set.
988
+ `page_paths` groups the list by the last segment of each path, so your posts
989
+ arrive in `app.pageList.posts`. Add more folders here later, and each gets its
990
+ own key. `sortBy: date` reads a post's `date` from the frontmatter and falls
991
+ back to `createdAt`, so your posts sort by the dates you just set.
868
992
 
869
993
  Now a page template that renders the page's own content and the list below it.
870
994
  Create `theme/views/pages/blog.pug`:
@@ -946,11 +1070,13 @@ if groups.length > 0
946
1070
  +pageListItems(group.pages)
947
1071
  ```
948
1072
 
949
- Each post becomes an `article` with its title, description and a "Read more"
950
- link, under the heading "Recent Pages". To change the heading or the markup, edit
951
- this file — it is your copy now. Running `npx nera-simple-page-list` again skips
952
- the folder because it already exists; `npx nera-simple-page-list --force`
953
- overwrites it with the shipped version and discards your edits.
1073
+ It reads `app.pageList` in either shape. For your config that is one group,
1074
+ `posts`: under the heading "Recent Pages" and a group heading "posts", each post
1075
+ becomes an `article` with its title, description and a "Read more" link. To
1076
+ change the headings or the markup, edit this file — it is your copy now.
1077
+ Running `npx nera add simple-page-list` again keeps your config and this folder.
1078
+ `npx nera-simple-page-list --force` overwrites the folder with the shipped
1079
+ template and discards your edits.
954
1080
 
955
1081
  Prefer to write the list yourself? See
956
1082
  [Write your own local plugin](https://nera.js.org/tutorials/write-a-local-plugin.html).
@@ -964,8 +1090,9 @@ Prefer to write the list yourself? See
964
1090
  - **Sitemap:** set your site's origin as in
965
1091
  [Add canonical links for SEO](https://nera.js.org/tutorials/canonical-links-seo.html), then add
966
1092
  `@nera-static/plugin-sitemap` from the [plugin catalog](https://nera.js.org/plugins/index.html).
967
- - **Images and code:** `@nera-static/plugin-images` (responsive images) and
968
- `@nera-static/plugin-code-blocks` (syntax highlighting) are in the
1093
+ - **Images and code:** `@nera-static/plugin-images` turns your photos into
1094
+ responsive images ([tutorial](https://nera.js.org/tutorials/responsive-images.html)), and
1095
+ `@nera-static/plugin-code-blocks` (syntax highlighting) is in the
969
1096
  [plugin catalog](https://nera.js.org/plugins/index.html) too.
970
1097
 
971
1098
  ## 5. Preview and build
@@ -996,22 +1123,19 @@ the link for the current page — no JavaScript required.
996
1123
  ## 1. Install and publish the template
997
1124
 
998
1125
  ```bash
999
- npm install @nera-static/plugin-navigation
1000
- npx nera-navigation
1126
+ npx nera add navigation
1001
1127
  ```
1002
1128
 
1003
- The second command copies the nav templates into
1129
+ `nera add` installs the package, copies its default `config/navigation.yaml` into
1130
+ your site and publishes the nav templates into
1004
1131
  `theme/views/vendor/plugin-navigation/`, where you can edit them freely.
1005
1132
 
1006
1133
  ## 2. Define the menu
1007
1134
 
1008
- Create `config/navigation.yaml`. A single flat menu looks like this:
1135
+ Open `config/navigation.yaml`, the file `nera add` copied. Its menu is a single flat
1136
+ list that already holds the Home link, so add your other pages below it:
1009
1137
 
1010
1138
  ```yaml
1011
- active_class: nav__link--active
1012
- active_path_class: nav__link--active-path
1013
- nav_class: nav
1014
-
1015
1139
  elements:
1016
1140
  - href: /index.html
1017
1141
  name: Home
@@ -1019,15 +1143,24 @@ elements:
1019
1143
  name: Docs
1020
1144
  ```
1021
1145
 
1022
- All three class keys are optional, and the values above are their defaults, so this
1023
- example renders the same as one without them. `active_class` goes on the link to the
1024
- current page, `active_path_class` on a section link — one pointing at a folder's index,
1146
+ Above the list the file carries the three class keys, commented out at their
1147
+ defaults:
1148
+
1149
+ ```yaml
1150
+ # nav_class: nav
1151
+ # active_class: nav__link--active
1152
+ # active_path_class: nav__link--active-path
1153
+ ```
1154
+
1155
+ Leave them commented out and the plugin uses exactly these values. `active_class`
1156
+ goes on the link to the current page, `active_path_class` on a section link — one pointing at a folder's index,
1025
1157
  such as `/docs/index.html` or `/docs/` — when the current page sits in that folder or below
1026
1158
  (the site root never counts). `nav_class` is the BEM block name the other classes derive
1027
1159
  from: `nav_class: mainmenu` renames the whole family to `.mainmenu`, `.mainmenu--list`,
1028
1160
  `.mainmenu__item`, `.mainmenu__link`, `.mainmenu__link--active` and
1029
1161
  `.mainmenu__link--active-path`. The two state keys override just their own class, so
1030
- when you rename, drop them — left as above, they keep `nav__link--active`.
1162
+ when you rename, leave them commented out — uncommented with the values above,
1163
+ they keep `nav__link--active`.
1031
1164
 
1032
1165
  Every entry needs an `href`: one without it is skipped with a warning, and the build
1033
1166
  still succeeds.
@@ -1037,8 +1170,8 @@ still succeeds.
1037
1170
  > `npx nera-navigation --force` once — it overwrites that folder, so if you edited your
1038
1171
  > copy, save your changes first and carry them over.
1039
1172
 
1040
- Need more than one menu? Nest them under names — each becomes
1041
- `app.nav.<name>.elements`:
1173
+ Need more than one menu? Replace the flat list with named ones — the copied file
1174
+ shows this shape in a comment at its end. Each becomes `app.nav.<name>.elements`:
1042
1175
 
1043
1176
  ```yaml
1044
1177
  elements:
@@ -1090,10 +1223,12 @@ a browsable overview page for every tag automatically.
1090
1223
  ## 1. Install and publish templates
1091
1224
 
1092
1225
  ```bash
1093
- npm install @nera-static/plugin-tags
1094
- npx nera-tags
1226
+ npx nera add tags
1095
1227
  ```
1096
1228
 
1229
+ `nera add` installs the package, copies its default `config/tags.yaml` into
1230
+ your site and publishes the templates into `theme/views/vendor/plugin-tags/`.
1231
+
1097
1232
  ## 2. Tag some pages
1098
1233
 
1099
1234
  Add a comma-separated `tags` value to any page's frontmatter:
@@ -1109,19 +1244,27 @@ tags: plugins, search
1109
1244
  Tags are slugified and case-folded, so `Web Dev`, `web dev` and `WEB DEV` all map to
1110
1245
  one page at `/tags/web-dev.html`.
1111
1246
 
1112
- ## 3. Configure (optional)
1247
+ ## 3. Configure
1113
1248
 
1114
- `config/tags.yaml` — every key is optional:
1249
+ `config/tags.yaml`, the file `nera add` copied, sets every key to its default,
1250
+ so it changes nothing until you edit it; the keys commented out in it are
1251
+ examples. These are the first four:
1115
1252
 
1116
1253
  ```yaml
1117
1254
  meta_property_name: tags
1118
1255
  tag_overview_path: '/tags'
1119
1256
  tag_separator: ','
1257
+ tag_overview_layout: pages/default.pug
1258
+ ```
1259
+
1260
+ `tag_overview_layout` is the layout every generated tag page renders with.
1261
+ Point it at a layout that renders the published overview template:
1262
+
1263
+ ```yaml
1120
1264
  tag_overview_layout: pages/tag-overview.pug
1121
1265
  ```
1122
1266
 
1123
- The `tag_overview_layout` points at a layout that renders the published overview
1124
- template. Create `theme/views/pages/tag-overview.pug`:
1267
+ Then create `theme/views/pages/tag-overview.pug`:
1125
1268
 
1126
1269
  ```pug
1127
1270
  extends ../layouts/layout
@@ -1168,7 +1311,7 @@ Tags are then collected per `meta.lang`, and the language code prefixes the whol
1168
1311
  ```
1169
1312
 
1170
1313
  The default language stays unprefixed, which is what you want when it is served
1171
- from the root. If every language sits in its own directory, add
1314
+ from the root. If every language sits in its own directory, set
1172
1315
  `prefix_default_lang: true` so it gets a segment too. Pages without a `meta.lang`
1173
1316
  fall into the default language rather than a bucket of their own, so a
1174
1317
  single-language site is unaffected by any of this.
@@ -1200,30 +1343,27 @@ client script — no server required.
1200
1343
  ## 1. Install
1201
1344
 
1202
1345
  ```bash
1203
- npm install @nera-static/plugin-search
1204
- ```
1205
-
1206
- ## 2. Publish the template
1207
-
1208
- ```bash
1209
- npx nera-search
1346
+ npx nera add search
1210
1347
  ```
1211
1348
 
1212
- This copies the search box into `theme/views/vendor/plugin-search/` and the client into
1349
+ `nera add` installs the package, copies its default `config/search.yaml` into
1350
+ your site and publishes the plugin's files: the search box into
1351
+ `theme/views/vendor/plugin-search/` and the client into
1213
1352
  `theme/assets/js/search.js`.
1214
1353
 
1215
- Both copies are yours from then on. Running `npx nera-search` again skips the
1216
- template if the `vendor/plugin-search/` folder exists and the client if
1217
- `search.js` exists, so it never discards your edits — and a template change in a
1354
+ Both copies are yours from then on. Running `npx nera add search` again, or
1355
+ the plugin's own `npx nera-search`, skips the template if the
1356
+ `vendor/plugin-search/` folder exists and the client if `search.js` exists, so
1357
+ it never discards your edits — and a template change in a
1218
1358
  new release never reaches your site on its own. To refresh after an upgrade, run
1219
1359
  `npx nera-search --force`, but only if you never edited the copies: it overwrites
1220
1360
  both. If you did, diff them against the package and merge the changes by hand
1221
1361
  (the plugin README's *Template Publishing* section explains how).
1222
1362
 
1223
- ## 3. Configure
1363
+ ## 2. Configure
1224
1364
 
1225
- `config/search.yaml` controls which fields are indexed. The file is optional;
1226
- these are the defaults:
1365
+ `config/search.yaml`, the file `nera add` copied, controls which fields are
1366
+ indexed. Its values are the defaults, so it changes nothing until you edit it:
1227
1367
 
1228
1368
  ```yaml
1229
1369
  fields:
@@ -1233,8 +1373,12 @@ fields:
1233
1373
  - href
1234
1374
  strip_html: true
1235
1375
  output_filename: search-index.json
1376
+ group_by_lang: false
1377
+ show_title: true
1236
1378
  ```
1237
1379
 
1380
+ `show_title` and `group_by_lang` come up in steps 3 and 4.
1381
+
1238
1382
  `fields` replaces the default list rather than extending it, so keep `content`
1239
1383
  (the page body) and `href` (the result link). Any other frontmatter key works if
1240
1384
  your pages define it — the starter page `nera new` scaffolds has a `description`
@@ -1251,7 +1395,7 @@ write the attribute on raw HTML:
1251
1395
  <aside data-search-ignore>Not part of the index.</aside>
1252
1396
  ```
1253
1397
 
1254
- ## 4. Add a search page
1398
+ ## 3. Add a search page
1255
1399
 
1256
1400
  The search box is Pug, so it belongs in a view, not in the Markdown. Create
1257
1401
  `theme/views/pages/search.pug` on top of the layout `nera new` scaffolds:
@@ -1280,14 +1424,15 @@ Search across the documentation.
1280
1424
  ```
1281
1425
 
1282
1426
  That page brings its own `# Search` heading, so turn off the template's `h1` in
1283
- `config/search.yaml`, or `nera build --check` warns `a11y-h1` about two of them:
1427
+ `config/search.yaml`, or `nera build --check` warns `a11y-h1` about two of them —
1428
+ set it to `false`:
1284
1429
 
1285
1430
  ```yaml
1286
1431
  show_title: false
1287
1432
  ```
1288
1433
 
1289
- If your page has no heading of its own, leave `show_title` out and the template's
1290
- `h1` is the page heading.
1434
+ If your page has no heading of its own, keep `show_title: true` and the
1435
+ template's `h1` is the page heading.
1291
1436
 
1292
1437
  The template's texts go through `t()`: `search_title` (the heading, default
1293
1438
  `Search`), `search_placeholder` (default `Search...`) and `search_label`, the
@@ -1311,11 +1456,11 @@ plugin-order:
1311
1456
  - plugin-search
1312
1457
  ```
1313
1458
 
1314
- ## 5. Per-language search (optional)
1459
+ ## 4. Per-language search (optional)
1315
1460
 
1316
1461
  By default every page lands in one index, so the search box on a German page
1317
- also returns English and Spanish hits. Set `group_by_lang` to give each language
1318
- an index of its own:
1462
+ also returns English and Spanish hits. Set `group_by_lang` to `true` to give
1463
+ each language an index of its own:
1319
1464
 
1320
1465
  ```yaml
1321
1466
  group_by_lang: true
@@ -1341,7 +1486,7 @@ the *default* language's index, so building the attribute from it would search
1341
1486
  English from a German page. `app.searchIndexPaths` has every language keyed by
1342
1487
  code, and each index entry carries its `lang`.
1343
1488
 
1344
- Because search runs last (step 4), pages other plugins generate land in the
1489
+ Because search runs last (step 3), pages other plugins generate land in the
1345
1490
  right language too — the tag pages from `plugin-tags` among them.
1346
1491
 
1347
1492
  Render, and you have working search. This site's [Search page](https://nera.js.org/search.html) is
@@ -1361,10 +1506,14 @@ docs and multi-part tutorials.
1361
1506
  ## 1. Install and publish the template
1362
1507
 
1363
1508
  ```bash
1364
- npm install @nera-static/plugin-page-pagination
1365
- npx nera-page-pagination
1509
+ npx nera add page-pagination
1366
1510
  ```
1367
1511
 
1512
+ `nera add` installs the package, copies its `config/page-pagination.yaml` into
1513
+ your site and publishes the template into
1514
+ `theme/views/vendor/plugin-page-pagination/`. The defaults need no setting, so
1515
+ the one key in that file is commented out.
1516
+
1368
1517
  ## 2. Order the pages
1369
1518
 
1370
1519
  By default the plugin reads a `pagination_order` number from each page:
@@ -1380,8 +1529,8 @@ Pages are ordered by `pagination_order` first, then by creation date, then by
1380
1529
  path — so a page without an explicit order still lands somewhere stable.
1381
1530
 
1382
1531
  > Ordering starts at `0` if you want it to: the plugin treats `0` as a real value,
1383
- > not "missing". Change the key name in `config/page-pagination.yaml` with
1384
- > `order_property` if you prefer.
1532
+ > not "missing". To read a different key, uncomment `order_property` in
1533
+ > `config/page-pagination.yaml` and set its name.
1385
1534
 
1386
1535
  ## 3. Render the links
1387
1536
 
@@ -1410,24 +1559,17 @@ without you touching the Markdown.
1410
1559
  ## 1. Install
1411
1560
 
1412
1561
  ```bash
1413
- npm install @nera-static/plugin-link-attributes
1562
+ npx nera add link-attributes
1414
1563
  ```
1415
1564
 
1416
- No template to publish — this plugin only transforms content. Its one setting
1417
- lives in a config file.
1565
+ `nera add` installs the package and copies its default `config/link-attributes.yaml`
1566
+ into your site. There is no template to publish — this plugin only transforms
1567
+ content, and its one setting lives in that file.
1418
1568
 
1419
1569
  ## 2. Configure
1420
1570
 
1421
- `config/link-attributes.yaml` lists the attributes to add. The quick way to get
1422
- it is the plugin's own command, which writes the defaults shown below:
1423
-
1424
- ```bash
1425
- npx nera-link-attributes
1426
- ```
1427
-
1428
- An existing file is left alone, so re-running never overwrites your edits;
1429
- `npx nera-link-attributes --force` replaces it with a fresh copy. You can also
1430
- write the file by hand:
1571
+ `config/link-attributes.yaml`, the file `nera add` copied, lists the attributes to
1572
+ add:
1431
1573
 
1432
1574
  ```yaml
1433
1575
  attributes:
@@ -1435,6 +1577,10 @@ attributes:
1435
1577
  - rel="noopener noreferrer"
1436
1578
  ```
1437
1579
 
1580
+ These defaults are what this tutorial wants, so you can keep the file as it is.
1581
+ Running `nera add` again keeps your edits; to get the defaults back, the plugin's
1582
+ own command `npx nera-link-attributes --force` replaces the file with a fresh copy.
1583
+
1438
1584
  Without any `attributes` the plugin leaves your pages unchanged — no file, no new
1439
1585
  tabs.
1440
1586
 
@@ -1470,14 +1616,14 @@ search console weeks later. So check the output, as this tutorial does at every
1470
1616
  ## 1. Install and publish the template
1471
1617
 
1472
1618
  ```bash
1473
- npm install @nera-static/plugin-canonical-links
1474
- npx nera-canonical-links
1619
+ npx nera add canonical-links
1475
1620
  ```
1476
1621
 
1477
- The second command copies `index.pug` and its `partials/` to
1478
- `theme/views/vendor/plugin-canonical-links/`. It skips if that folder already
1479
- exists, so your edits are safe; `npx nera-canonical-links --force` overwrites them
1480
- with the shipped templates after an upgrade.
1622
+ `nera add` installs the package, copies its default `config/canonical-links.yaml`
1623
+ into your site and publishes `index.pug` and its `partials/` to
1624
+ `theme/views/vendor/plugin-canonical-links/`. Publishing skips if that folder
1625
+ already exists, so your edits are safe; `npx nera-canonical-links --force`
1626
+ overwrites them with the shipped templates after an upgrade.
1481
1627
 
1482
1628
  ## 2. Set your origin
1483
1629
 
@@ -1488,10 +1634,14 @@ Canonical URLs are absolute, so the plugin needs your site's origin. Set it once
1488
1634
  origin: https://example.com
1489
1635
  ```
1490
1636
 
1491
- That is all the configuration a single-language site needs — **the plugin's own
1492
- config file is optional**. If you do create `config/canonical-links.yaml`, its
1493
- `app_origin` is used as a fallback when `app.yaml` has no `origin`; when both are
1494
- set, `origin` in `app.yaml` wins. A trailing slash is stripped either way.
1637
+ That is all the configuration a single-language site needs — **the
1638
+ `config/canonical-links.yaml` that `nera add` copied can stay as it is**. Its
1639
+ one active key, `page_identifier: slug`, is the default, and the others are
1640
+ commented-out examples. One of them, `app_origin`, is used as a fallback when
1641
+ `app.yaml` has no `origin`; when both are set, `origin` in `app.yaml` wins. A
1642
+ trailing slash is stripped either way. A file copied before plugin-canonical-links 2.2.4 set
1643
+ `app_origin: https://example.com` and `available_languages` as active samples:
1644
+ delete those two keys, or set them to your own values.
1495
1645
 
1496
1646
  With no origin at all, the plugin emits no canonical or alternate links and prints
1497
1647
  one warning during the build:
@@ -1542,8 +1692,8 @@ Build and view the source of `pages/getting-started.md` — you'll see:
1542
1692
 
1543
1693
  ## 4. Link translations with hreflang
1544
1694
 
1545
- Alternate-language links need three things. First, list your languages in
1546
- `config/canonical-links.yaml`:
1695
+ Alternate-language links need three things. First, uncomment
1696
+ `available_languages` in `config/canonical-links.yaml` and list your languages:
1547
1697
 
1548
1698
  ```yaml
1549
1699
  page_identifier: slug
@@ -1553,8 +1703,8 @@ available_languages:
1553
1703
  ```
1554
1704
 
1555
1705
  `page_identifier` names the frontmatter key that marks two pages as translations
1556
- of each other; `slug` is the default, so you can leave the line out. Second, every
1557
- page sets its `lang`. Third, translations share an identical `slug`:
1706
+ of each other; `slug` is the default, and the copied file already sets it.
1707
+ Second, every page sets its `lang`. Third, translations share an identical `slug`:
1558
1708
 
1559
1709
  ```markdown
1560
1710
  ---
@@ -1624,7 +1774,11 @@ Generated pages have no `slug`, so they get a canonical link and no alternates.
1624
1774
  The sitemap plugin, [`@nera-static/plugin-sitemap`](https://www.npmjs.com/package/@nera-static/plugin-sitemap),
1625
1775
  reads the same origin (`origin` in `app.yaml`, else `app_origin`) and the same
1626
1776
  `base_path`, so the URLs in your sitemap and your canonical links agree — on a
1627
- `base_path` site from plugin-canonical-links 2.2.3 on.
1777
+ `base_path` site from plugin-canonical-links 2.2.3 on. Add it the same way:
1778
+
1779
+ ```bash
1780
+ npx nera add sitemap
1781
+ ```
1628
1782
 
1629
1783
  This site uses the plugin as well, set up as this tutorial describes:
1630
1784
  `origin: https://nera.js.org` in `config/app.yaml`, the root-absolute include in its layout,
@@ -1811,11 +1965,13 @@ in any view through `app.stacks`. Several blocks that form one section become a
1811
1965
  ## 1. Install
1812
1966
 
1813
1967
  ```bash
1814
- npm install @nera-static/plugin-stacks
1968
+ npx nera add stacks
1815
1969
  ```
1816
1970
 
1817
- Nera finds the plugin on its own. It needs no config file: stacks are defined
1818
- in frontmatter.
1971
+ `nera add` installs the package and publishes its default template into
1972
+ `theme/views/vendor/plugin-stacks/` (section 4). It copies no config file, as
1973
+ the plugin needs none: stacks are defined in frontmatter. Nera finds the plugin
1974
+ on its own.
1819
1975
 
1820
1976
  ## 2. What makes a page a stack
1821
1977
 
@@ -1868,15 +2024,10 @@ plugin warns.
1868
2024
 
1869
2025
  ## 4. Render a stack through a template
1870
2026
 
1871
- A stack can bring its own markup. Publish the plugin's default template:
1872
-
1873
- ```bash
1874
- npx nera-stacks
1875
- ```
1876
-
1877
- It lands in `theme/views/vendor/plugin-stacks/stack-template.pug`. Point a
1878
- stack at it with **`stack_layout`**, a path from the **project root** (where
1879
- you run `nera build`), not from the views folder:
2027
+ A stack can bring its own markup. `nera add` already published the plugin's
2028
+ default template to `theme/views/vendor/plugin-stacks/stack-template.pug`.
2029
+ Point a stack at it with **`stack_layout`**, a path from the **project root**
2030
+ (where you run `nera build`), not from the views folder:
1880
2031
 
1881
2032
  ```markdown:pages/stacks/call-to-action.md
1882
2033
  ---
@@ -2082,17 +2233,18 @@ you add a category, `notice: false` no longer applies, and the build says so:
2082
2233
  ## 2. Install and wire the layout
2083
2234
 
2084
2235
  ```bash
2085
- npm install @nera-static/plugin-consent
2086
- npx nera-consent-config
2087
- npx nera-consent
2236
+ npx nera add consent
2088
2237
  ```
2089
2238
 
2090
- `npx nera-consent-config` copies the documented `config/consent.yaml`, every
2091
- example commented out, so the site starts in notice mode. `npx nera-consent`
2092
- copies the five views (`banner`, `settings`, `notice`, `head`, `embed`). On a
2093
- site scaffolded with `nera new`, they land in
2094
- `theme/views/vendor/plugin-consent/`. Both commands skip a file or folder that
2095
- already exists; `--force` overwrites it, and your edits with it.
2239
+ `nera add` installs the package, copies its documented `config/consent.yaml`
2240
+ and publishes the five views (`banner`, `settings`, `notice`, `head`, `embed`)
2241
+ into `theme/views/vendor/plugin-consent/`. In the copied file `revision` and
2242
+ `notice` are set to their defaults and every example (`privacy_url`,
2243
+ `categories`, `texts`) is commented out, so the site starts in notice mode.
2244
+ Until you set `privacy_url`, the build warns that the notice links no privacy
2245
+ policy. `nera add` keeps a `config/consent.yaml` or a views folder that already
2246
+ exists. To overwrite them with the plugin's current versions, and your edits
2247
+ with them, run `npx nera-consent-config --force` and `npx nera-consent --force`.
2096
2248
 
2097
2249
  Plugins cannot touch your layout, so this is the one manual step. Add the
2098
2250
  stylesheet, the `head` view and the runtime inside `<head>`, a settings link
@@ -2563,22 +2715,22 @@ fit together.
2563
2715
  ```bash
2564
2716
  npx @nera-static/nera new my-site
2565
2717
  cd my-site
2566
- npm install @nera-static/plugin-one-page @nera-static/plugin-page-navigation \
2567
- @nera-static/plugin-contact-form @nera-static/plugin-social-media-links
2568
- ```
2569
-
2570
- Nera finds all four plugins on its own. Three of them ship templates. Publish
2571
- them into your views folder, where they are yours to edit:
2572
-
2573
- ```bash
2574
- npx nera-page-navigation
2575
- npx nera-contact-form
2576
- npx nera-social-media-links
2577
- ```
2578
-
2579
- On a `nera new` site they land in `theme/views/vendor/plugin-<name>/`, and the
2580
- contact form's client script in `theme/assets/js/contact-form.js`.
2581
- `plugin-one-page` ships no template and needs no config file.
2718
+ npx nera add one-page
2719
+ npx nera add page-navigation
2720
+ npx nera add contact-form
2721
+ npx nera add social-media-links
2722
+ ```
2723
+
2724
+ `nera add` takes one plugin per call. Each call installs the package, which
2725
+ Nera then finds on its own, and copies the plugin's default config into
2726
+ `config/`. Three of the four ship templates, and `nera add` publishes them into
2727
+ `theme/views/vendor/plugin-<name>/`, where they are yours to edit. The contact
2728
+ form's client script lands in `theme/assets/js/contact-form.js`.
2729
+ `plugin-one-page` ships no template. Its copied `config/one-page.yaml` only
2730
+ names the frontmatter keys it reads (`add_to_page`, `add_to_page_order`,
2731
+ `anchor_id` and the others). Leave it as it is, and
2732
+ `config/page-navigation.yaml` too, which sets the class of the active link.
2733
+ Steps 7 and 8 replace the other two files.
2582
2734
 
2583
2735
  ## 2. The target page
2584
2736
 
@@ -2847,7 +2999,9 @@ live in each page's frontmatter, next to the content they point to.
2847
2999
 
2848
3000
  ## 7. The contact form
2849
3001
 
2850
- `plugin-contact-form` renders a form from `config/contact-form.yaml`. On submit
3002
+ `plugin-contact-form` renders a form from `config/contact-form.yaml`. The copy
3003
+ `nera add` made documents every key, with the recipient commented out and a
3004
+ set of sample fields; replace it with this one. On submit
2851
3005
  a small script in the browser builds a `mailto:` link from the fields and opens
2852
3006
  the visitor's own email program with subject and message filled in. There is no
2853
3007
  backend: your site stores and sends nothing, and the message leaves only through
@@ -2961,7 +3115,8 @@ fields.` in the status line. Three details are worth knowing:
2961
3115
  ## 8. Social links in the footer
2962
3116
 
2963
3117
  `plugin-social-media-links` reads a list of links from
2964
- `config/social-media-links.yaml`:
3118
+ `config/social-media-links.yaml`. In the copy `nera add` made, the list is a
3119
+ commented-out example, so nothing renders yet. Replace the file with:
2965
3120
 
2966
3121
  ```yaml:config/social-media-links.yaml
2967
3122
  aria_label: Social media
@@ -2979,9 +3134,9 @@ social_media_links:
2979
3134
  The `d` attribute is shortened here; paste the full path of the icon you use.
2980
3135
  Simple Icons (simpleicons.org) has brand logos as SVG. `icon` is escaped unless
2981
3136
  the entry sets `icon_raw: true`, so set it only for markup you wrote or checked
2982
- yourself. The LinkedIn entry has no icon and shows its name only. The plugin's
2983
- sample config uses Font Awesome `<i>` tags instead, which need the Font Awesome
2984
- CSS. Loading it from a CDN sends every visitor's IP address to a third party,
3137
+ yourself. The LinkedIn entry has no icon and shows its name only. The example
3138
+ list in the copied config uses Font Awesome `<i>` tags instead, which need the
3139
+ Font Awesome CSS. Loading it from a CDN sends every visitor's IP address to a third party,
2985
3140
  and `nera build --check` then warns `privacy-third-party`. Inline SVG or plain
2986
3141
  text needs no request at all.
2987
3142
 
@@ -3199,6 +3354,413 @@ particular spot of a layout.
3199
3354
  - [How this website is built](https://nera.js.org/tutorials/how-this-site-is-built.html) shows a
3200
3355
  complete Nera site with its plugins working together.
3201
3356
 
3357
+ # Responsive images with plugin-images
3358
+
3359
+ Source: https://nera.js.org/tutorials/responsive-images.html
3360
+
3361
+ A photo straight from a camera or a phone is several megabytes and thousands
3362
+ of pixels wide, and it carries metadata: the camera model, the time, often
3363
+ the GPS position where it was taken. Put it into a Markdown page as it is,
3364
+ and every visitor downloads all of that, on a phone too.
3365
+ `@nera-static/plugin-images` fixes this at build time. Every local image in
3366
+ your Markdown becomes a `<picture>` with AVIF and WebP in several widths,
3367
+ `srcset`/`sizes`, `width`/`height` and lazy loading, and the published files
3368
+ carry no metadata. Your Markdown does not change.
3369
+
3370
+ Every command, config and output below was run in a fresh `nera new` site
3371
+ with plugin-images 1.0.3, `@nera-static/core` 4.18.3 and
3372
+ `@nera-static/nera` 1.27.2. The photo is a 4000 × 3000 JPEG of 4 MB with
3373
+ camera and GPS data in its EXIF block.
3374
+
3375
+ ## 1. Install
3376
+
3377
+ ```bash
3378
+ npx nera add images
3379
+ ```
3380
+
3381
+ `nera add` installs the package and publishes the plugin's one view, the
3382
+ `picture` mixin, into `theme/views/vendor/plugin-images/`:
3383
+
3384
+ ```text
3385
+ ✅ Copied picture.pug to …/theme/views/vendor/plugin-images/picture.pug
3386
+ ✅ Templates copied to: …/theme/views/vendor/plugin-images
3387
+ ✅ Added @nera-static/plugin-images
3388
+ Config: none (the plugin ships no default)
3389
+ Templates: published by the plugin
3390
+ ```
3391
+
3392
+ There is nothing else to set up: a `config/images.yaml` is optional, and so
3393
+ is every key in it. The blog, business and portfolio starters
3394
+ (`nera new --starter …`) already ship the plugin.
3395
+
3396
+ ## 2. Before and after
3397
+
3398
+ Put the photo into the site's assets, at
3399
+ `theme/assets/images/photos/pier.jpg`, and use it in a page like any image:
3400
+
3401
+ ```markdown:pages/pier.md
3402
+ ---
3403
+ layout: pages/default.pug
3404
+ title: The pier
3405
+ description: A photo of the pier at dusk
3406
+ ---
3407
+ # The pier
3408
+
3409
+ ![The pier at dusk, seen from the beach](https://nera.js.org/images/photos/pier.jpg)
3410
+ ```
3411
+
3412
+ Without the plugin, `nera build` turns this into a plain `<img>` that points
3413
+ at the 4 MB original:
3414
+
3415
+ ```html
3416
+ <p><img src="/images/photos/pier.jpg" alt="The pier at dusk, seen from the beach"></p>
3417
+ ```
3418
+
3419
+ With the plugin, the first build encodes the variants:
3420
+
3421
+ ```text
3422
+ 🖼️ plugin-images: 1 image(s), 12 variant(s) encoded
3423
+ ```
3424
+
3425
+ and `public/pier.html` holds:
3426
+
3427
+ ```html
3428
+ <p>
3429
+ <picture>
3430
+ <source type="image/avif" srcset="/_img/pier-1a5869e3-480.avif 480w, /_img/pier-1a5869e3-800.avif 800w, /_img/pier-1a5869e3-1200.avif 1200w, /_img/pier-1a5869e3-1600.avif 1600w" sizes="100vw">
3431
+ <source type="image/webp" srcset="/_img/pier-987422b0-480.webp 480w, /_img/pier-987422b0-800.webp 800w, /_img/pier-987422b0-1200.webp 1200w, /_img/pier-987422b0-1600.webp 1600w" sizes="100vw"><img src="/_img/pier-10e7e41a-1600.jpg" srcset="/_img/pier-10e7e41a-480.jpg 480w, /_img/pier-10e7e41a-800.jpg 800w, /_img/pier-10e7e41a-1200.jpg 1200w, /_img/pier-10e7e41a-1600.jpg 1600w" sizes="100vw" width="1600" height="1200" alt="The pier at dusk, seen from the beach" loading="eager" fetchpriority="high">
3432
+ </picture>
3433
+ </p>
3434
+ ```
3435
+
3436
+ - The browser picks the first format it supports, AVIF, then WebP, and the
3437
+ `<img>` is the fallback. It keeps the source's format (JPEG stays JPEG, PNG
3438
+ stays PNG) and always points at a processed variant, never the original.
3439
+ - The widths are the default `480, 800, 1200, 1600`. A source is never
3440
+ upscaled: a photo 1000 pixels wide gets 480 and 800 only.
3441
+ - `width` and `height` are the largest variant's size, so the browser
3442
+ reserves the space before the image loads and the page does not jump.
3443
+ - The first image on a page loads eagerly with `fetchpriority="high"`, since
3444
+ it is usually the largest thing on the screen. Every later image gets
3445
+ `loading="lazy" decoding="async"`.
3446
+ - `alt` and every other attribute of your image are kept. The plugin never
3447
+ writes an `alt` for you.
3448
+
3449
+ The variants land in `public/_img/`, with a hash of the source and the
3450
+ settings in each name, so a URL changes only when the image does. The
3451
+ variants carry no EXIF, GPS or ICC data: the plugin applies the EXIF
3452
+ orientation and then strips all of it.
3453
+
3454
+ On the plugin's field-test site, a German/English blog, the 32 content images
3455
+ went from 4.2 MB of originals to 0.45 MB of AVIF a phone downloads.
3456
+
3457
+ The plugin leaves alone what it should not touch: SVG and GIF, external
3458
+ `http(s)://` URLs, an `<img>` that already has a `srcset` or sits inside a
3459
+ `<picture>`, and any image with `?skip` on its URL. An image file that does
3460
+ not exist stays a plain `<img>`, and the build says so:
3461
+
3462
+ ```text
3463
+ ⚠️ plugin-images: /pier.html: image not found, left as is: /images/photos/missing.jpg
3464
+ ```
3465
+
3466
+ Images in your Pug **views** are not processed. For those, use frontmatter
3467
+ images and the mixin (step 5).
3468
+
3469
+ ## 3. Query parameters
3470
+
3471
+ Add parameters to the image URL to change one image. The parameters never
3472
+ reach the published URLs. This one is at most 800 pixels wide, cropped to
3473
+ 16:9 around a point 30 % from the left and 60 % from the top:
3474
+
3475
+ ```markdown:pages/pier.md
3476
+ ![The end of the pier](https://nera.js.org/images/photos/pier.jpg?w=800&ratio=16:9&focus=30,60)
3477
+ ```
3478
+
3479
+ ```html
3480
+ <picture>
3481
+ <source type="image/avif" srcset="/_img/pier-7a863ccf-480.avif 480w, /_img/pier-7a863ccf-800.avif 800w, /_img/pier-7a863ccf-1600.avif 1600w" sizes="(min-width: 800px) 800px, 100vw">
3482
+ <source type="image/webp" srcset="/_img/pier-f3e554c6-480.webp 480w, /_img/pier-f3e554c6-800.webp 800w, /_img/pier-f3e554c6-1600.webp 1600w" sizes="(min-width: 800px) 800px, 100vw"><img src="/_img/pier-85ac4388-1600.jpg" srcset="/_img/pier-85ac4388-480.jpg 480w, /_img/pier-85ac4388-800.jpg 800w, /_img/pier-85ac4388-1600.jpg 1600w" sizes="(min-width: 800px) 800px, 100vw" width="1600" height="900" alt="The end of the pier" loading="lazy" decoding="async">
3483
+ </picture>
3484
+ ```
3485
+
3486
+ `?w=800` keeps the configured widths below 800, adds 800 and 1600 (for
3487
+ screens with twice the pixel density) and sets a matching `sizes`. The crop
3488
+ makes the image 1600 × 900. The parameters:
3489
+
3490
+ | Parameter | What it does | Example |
3491
+ |---|---|---|
3492
+ | `w` | Maximum display width in pixels | `?w=800` |
3493
+ | `h` | Target height; with `w` it crops | `?w=800&h=450` |
3494
+ | `ratio` | Crop to an aspect ratio | `?ratio=16:9` |
3495
+ | `fit` | `cover` (the default for a crop), `contain` or `inside` | `?fit=contain` |
3496
+ | `focus` | Focal point of a crop in percent, or `attention` / `entropy` | `?focus=30,60` |
3497
+ | `q` | Quality for all formats, 1–100 | `?q=60` |
3498
+ | `formats` | Modern formats for this image, or `none` | `?formats=webp` |
3499
+ | `sizes` | `sizes` for this image, URL-encoded | `?sizes=50vw` |
3500
+ | `loading` | `eager` or `lazy`, overriding the first-image rule | `?loading=eager` |
3501
+ | `skip` | Leave this image untouched | `?skip` |
3502
+
3503
+ A parameter the plugin does not know is ignored with a warning, so a typo
3504
+ does not go unnoticed:
3505
+
3506
+ ```text
3507
+ ⚠️ plugin-images: /pier.html: unknown parameter "width" ignored: /images/photos/pier.jpg?width=800
3508
+ ```
3509
+
3510
+ ## 4. Captions
3511
+
3512
+ Give an image a Markdown title, and put it alone in its paragraph:
3513
+
3514
+ ```markdown:pages/pier.md
3515
+ ![The pier at dusk](https://nera.js.org/images/photos/pier.jpg "Usedom, October 2026")
3516
+ ```
3517
+
3518
+ It becomes a `<figure>` with the title as its caption. The `<figure>`
3519
+ replaces the paragraph, since a `<figure>` inside a `<p>` is invalid HTML:
3520
+
3521
+ ```html
3522
+ <figure class="nera-image">
3523
+ <picture>
3524
+ <source type="image/avif" srcset="/_img/pier-1a5869e3-480.avif 480w, /_img/pier-1a5869e3-800.avif 800w, /_img/pier-1a5869e3-1200.avif 1200w, /_img/pier-1a5869e3-1600.avif 1600w" sizes="100vw">
3525
+ <source type="image/webp" srcset="/_img/pier-987422b0-480.webp 480w, /_img/pier-987422b0-800.webp 800w, /_img/pier-987422b0-1200.webp 1200w, /_img/pier-987422b0-1600.webp 1600w" sizes="100vw"><img src="/_img/pier-10e7e41a-1600.jpg" srcset="/_img/pier-10e7e41a-480.jpg 480w, /_img/pier-10e7e41a-800.jpg 800w, /_img/pier-10e7e41a-1200.jpg 1200w, /_img/pier-10e7e41a-1600.jpg 1600w" sizes="100vw" width="1600" height="1200" alt="The pier at dusk" loading="lazy" decoding="async">
3526
+ </picture>
3527
+ <figcaption class="nera-image__caption">Usedom, October 2026</figcaption>
3528
+ </figure>
3529
+ ```
3530
+
3531
+ The same photo as in step 2 reuses the same variants: nothing is encoded
3532
+ twice. An image inline with text, inside a link or next to another image
3533
+ keeps its `title` and gets no figure. `figure: false` in
3534
+ `config/images.yaml` turns captions off. The classes `nera-image` and
3535
+ `nera-image__caption` are the plugin's public markup, so style them in your
3536
+ own CSS.
3537
+
3538
+ ## 5. Frontmatter images and the `+picture` mixin
3539
+
3540
+ A blog post's hero or teaser image usually sits in the frontmatter and is
3541
+ rendered by a view, not by the Markdown. Name it under `image`:
3542
+
3543
+ ```markdown:pages/beach.md
3544
+ ---
3545
+ layout: pages/post.pug
3546
+ title: A day at the beach
3547
+ description: A post with a hero image
3548
+ image: /images/photos/beach.jpg
3549
+ image_alt: Waves on an empty beach
3550
+ ---
3551
+ # A day at the beach
3552
+
3553
+ The hero image above comes from the frontmatter.
3554
+ ```
3555
+
3556
+ The plugin encodes the variants for it and puts the finished data into
3557
+ `meta.images.image`: `src`, `srcset`, `sizes`, `width`, `height`, the
3558
+ `sources` per format, and an `og` crop. `meta.image` itself stays the string
3559
+ you wrote, so views and plugins that read it keep working. Query parameters
3560
+ work here too (`image: /images/photos/beach.jpg?ratio=16:9`). More keys
3561
+ than `image` go into `frontmatter_keys` in `config/images.yaml`.
3562
+
3563
+ The mixin `nera add` published renders the entry:
3564
+
3565
+ ```pug:theme/views/pages/post.pug
3566
+ extends ../layouts/layout
3567
+
3568
+ block content
3569
+ main#main
3570
+ include /vendor/plugin-images/picture
3571
+ +picture(meta.images && meta.images.image, { alt: meta.image_alt, loading: 'eager' })
3572
+ != content
3573
+ ```
3574
+
3575
+ ```html
3576
+ <picture>
3577
+ <source type="image/avif" srcset="/_img/beach-04a0334d-480.avif 480w, /_img/beach-04a0334d-800.avif 800w, /_img/beach-04a0334d-1200.avif 1200w, /_img/beach-04a0334d-1600.avif 1600w" sizes="100vw" />
3578
+ <source type="image/webp" srcset="/_img/beach-2fc7c78b-480.webp 480w, /_img/beach-2fc7c78b-800.webp 800w, /_img/beach-2fc7c78b-1200.webp 1200w, /_img/beach-2fc7c78b-1600.webp 1600w" sizes="100vw" /><img src="/_img/beach-376379b1-1600.jpg" srcset="/_img/beach-376379b1-480.jpg 480w, /_img/beach-376379b1-800.jpg 800w, /_img/beach-376379b1-1200.jpg 1200w, /_img/beach-376379b1-1600.jpg 1600w" sizes="100vw" width="1600" height="1200" alt="Waves on an empty beach" loading="eager" fetchpriority="high" />
3579
+ </picture>
3580
+ ```
3581
+
3582
+ A page without the frontmatter key renders nothing there. The mixin's options
3583
+ are `alt`, `class`, `sizes` and `loading` (`lazy` by default; `eager` adds
3584
+ `fetchpriority="high"`). A hero above the content is the page's largest
3585
+ image, so render it with `loading: 'eager'` as above, and set
3586
+ `eager_first: false` in `config/images.yaml`, so the first Markdown image
3587
+ below it does not compete for the same priority.
3588
+
3589
+ ### `og:image`
3590
+
3591
+ The `og` entry is a 1200 × 630 JPEG, the size link previews in social
3592
+ networks and chat apps expect. `og:image` must be an absolute URL, so set
3593
+ your origin in `config/app.yaml`:
3594
+
3595
+ ```yaml:config/app.yaml
3596
+ origin: https://example.com
3597
+ ```
3598
+
3599
+ and add the tags inside the layout's `head`, after the other `meta` tags:
3600
+
3601
+ ```pug:theme/views/layouts/layout.pug
3602
+ if meta.images && meta.images.image && meta.images.image.og
3603
+ - const og = meta.images.image.og
3604
+ meta(property="og:image" content=`${app.origin}${app.basePath || ''}${og.src}`)
3605
+ meta(property="og:image:width" content=og.width)
3606
+ meta(property="og:image:height" content=og.height)
3607
+ ```
3608
+
3609
+ `public/beach.html` then has:
3610
+
3611
+ ```html
3612
+ <meta property="og:image" content="https://example.com/_img/beach-a82641dd-1200.jpg" />
3613
+ <meta property="og:image:width" content="1200" />
3614
+ <meta property="og:image:height" content="630" />
3615
+ ```
3616
+
3617
+ `app.basePath` is there for a site served from a subfolder: core rewrites
3618
+ `href` and `src` for `base_path`, but not the `content` of a `<meta>`.
3619
+
3620
+ ## 6. Placeholders
3621
+
3622
+ While an image loads, its box is empty. A placeholder fills it:
3623
+
3624
+ ```yaml:config/images.yaml
3625
+ placeholder: color
3626
+ ```
3627
+
3628
+ sets the image's dominant colour as its background:
3629
+
3630
+ ```html
3631
+ <img src="/_img/pier-10e7e41a-1600.jpg" srcset="/_img/pier-10e7e41a-480.jpg 480w, /_img/pier-10e7e41a-800.jpg 800w, /_img/pier-10e7e41a-1200.jpg 1200w, /_img/pier-10e7e41a-1600.jpg 1600w" sizes="100vw" width="1600" height="1200" style="background-color:#383898" alt="The pier at dusk, seen from the beach" loading="eager" fetchpriority="high">
3632
+ ```
3633
+
3634
+ `placeholder: blur` sets a tiny blurred WebP instead, inline in the page:
3635
+
3636
+ ```html
3637
+ <img src="/_img/pier-10e7e41a-1600.jpg" srcset="/_img/pier-10e7e41a-480.jpg 480w, /_img/pier-10e7e41a-800.jpg 800w, /_img/pier-10e7e41a-1200.jpg 1200w, /_img/pier-10e7e41a-1600.jpg 1600w" sizes="100vw" width="1600" height="1200" style="background-image:url(data:image/webp;base64,UklGRkIAAABXRUJQVlA4IDYAAACwAQCdASoQAAwAAsBMJbACdAEOtNWAAP7xfmtUemnWsBu+y/mBlsjTsVhsr/7FRn95mxzwAAA=);background-size:cover" alt="The pier at dusk, seen from the beach" loading="eager" fetchpriority="high">
3638
+ ```
3639
+
3640
+ The build reports them:
3641
+
3642
+ ```text
3643
+ 🖼️ plugin-images: 4 image(s), 0 variant(s) encoded, 3 placeholder(s) computed
3644
+ ```
3645
+
3646
+ Both work for Markdown images and for frontmatter images (the mixin renders
3647
+ the `style`). An image with transparency gets none, because the background
3648
+ would stay visible through it. The default is `none`, because a placeholder
3649
+ is an inline `style` attribute, which a Content Security Policy without
3650
+ `'unsafe-inline'` in `style-src` blocks.
3651
+
3652
+ A value the plugin does not know, or a key it does not know, warns and falls
3653
+ back to the default; neither fails the build:
3654
+
3655
+ ```text
3656
+ ⚠️ plugin-images: config/images.yaml: invalid placeholder "smudge", using "none"
3657
+ ⚠️ plugin-images: config/images.yaml: ignoring unknown key "width"
3658
+ ```
3659
+
3660
+ ## 7. Keep your originals off the server
3661
+
3662
+ The variants are clean, but by default the original is still published: in
3663
+ step 2, `public/images/photos/pier.jpg` is the 4 MB file with its camera and
3664
+ GPS data, reachable by anyone who guesses the URL. The plugin reads images
3665
+ from the assets folder **regardless of `.neraignore`**, so list the photo
3666
+ folder there:
3667
+
3668
+ ```text:.neraignore
3669
+ images/photos
3670
+ ```
3671
+
3672
+ The paths are relative to the assets folder. After the next build,
3673
+ `public/` has no `images/` folder at all; the pages still show every photo,
3674
+ from `public/_img/`. The originals stay in your repository.
3675
+
3676
+ Check first what else lives in that folder. `.neraignore` matches exact
3677
+ paths and folder prefixes, no glob patterns, and everything in a listed
3678
+ folder the plugin does not process is no longer published: SVGs, GIFs,
3679
+ files you link for download, and images your views use directly, such as an
3680
+ `img(src=meta.image)` or an `og:image` built from `meta.image`. Render those
3681
+ from `meta.images` (step 5). A folder that holds only photos for your pages is
3682
+ the safe case.
3683
+
3684
+ `nera build --check` looks at the built `public/`, for third-party requests
3685
+ among other things; the [CLI reference](https://nera.js.org/docs/cli.html#checking-the-built-site)
3686
+ describes the checks. For this site it reports:
3687
+
3688
+ ```text
3689
+ ✓ No problems found.
3690
+ ```
3691
+
3692
+ ## 8. The cache, locally and in CI
3693
+
3694
+ Encoding AVIF is slow. The plugin therefore keeps every variant in
3695
+ `.nera-cache/images/` and encodes only what is missing. With the test site's
3696
+ four images (three on the pier page, the hero of the beach post), a build
3697
+ with an empty cache reports:
3698
+
3699
+ ```text
3700
+ 🖼️ plugin-images: 4 image(s), 34 variant(s) encoded
3701
+ ```
3702
+
3703
+ and took 5.3 seconds; the next build:
3704
+
3705
+ ```text
3706
+ 🖼️ plugin-images: 4 image(s), 0 variant(s) encoded
3707
+ ```
3708
+
3709
+ took 0.9. On a site with a hundred photos, a cold build takes a minute or
3710
+ more. Variants no page uses any more are removed from the cache
3711
+ (`prune: true`).
3712
+
3713
+ `nera new` lists `.nera-cache` in the site's `.gitignore` (since
3714
+ `@nera-static/nera` 1.4.1), so the cache never lands in your repository. In
3715
+ CI, keep it between runs instead. The deploy workflow `nera publish` writes
3716
+ already does that (since `@nera-static/nera` 1.22.0). In a workflow of your
3717
+ own, add this step before `npm run build`:
3718
+
3719
+ ```yaml
3720
+ - uses: actions/cache@v6
3721
+ with:
3722
+ path: .nera-cache
3723
+ key: nera-cache-${{ hashFiles('assets/**', 'theme/assets/**', 'pages/**', 'config/images.yaml', 'package-lock.json') }}
3724
+ restore-keys: nera-cache-
3725
+ ```
3726
+
3727
+ The key covers `pages/**` because pages ask for variants (query parameters,
3728
+ frontmatter images), and `package-lock.json` because a theme from npm brings
3729
+ its own images. `actions/cache` saves nothing when the key matches exactly,
3730
+ so a key that misses one of them leaves new variants unsaved, and every build
3731
+ encodes them again.
3732
+
3733
+ ## 9. Requirements
3734
+
3735
+ The plugin needs **`@nera-static/core` 4.13.0 or later**: it hands its
3736
+ variants to core through the `getAssets` hook, which copies them into
3737
+ `public/`. Every current `@nera-static/nera` brings a newer core. On an older
3738
+ core the build stops, rather than publish pages that link to images which
3739
+ were never copied. With core 4.12.0:
3740
+
3741
+ ```text
3742
+ ❌ plugin-images: @nera-static/core 4.12.0 is too old; this plugin needs >= 4.13.0 (the getAssets hook). Without it, pages would link to image files that are never copied to public/. Update with `npm update @nera-static/nera` (or `@nera-static/core`).
3743
+ ```
3744
+
3745
+ The build exits with code 1.
3746
+
3747
+ The encoding runs on [sharp](https://sharp.pixelplumbing.com), a native
3748
+ module. It installs a prebuilt binary for your platform (macOS, Linux and
3749
+ Windows, on x64 and arm64), and the site's `package-lock.json` lists the
3750
+ binaries of every platform as optional dependencies, so `npm ci` on a Linux
3751
+ CI runner picks its own even when the lockfile was written on a Mac. Do not
3752
+ install with `--omit=optional`, which leaves the binary out. The plugin needs
3753
+ Node.js 20.18.1 or later.
3754
+
3755
+ The plugin's [README](https://github.com/seebaermichi/nera-plugin-images#readme)
3756
+ and [npm page](https://www.npmjs.com/package/@nera-static/plugin-images) have
3757
+ every config key with its default.
3758
+
3759
+ ## Next
3760
+
3761
+ [How this website is built](https://nera.js.org/tutorials/how-this-site-is-built.html) shows the
3762
+ plugins of this site working together.
3763
+
3202
3764
  # How this website is built
3203
3765
 
3204
3766
  Source: https://nera.js.org/tutorials/how-this-site-is-built.html
@@ -3261,8 +3823,9 @@ ordering is load-bearing on this site.
3261
3823
  ## Templates we own
3262
3824
 
3263
3825
  Plugins that ship views were published into `theme/views/vendor/` with commands like
3264
- `npx nera-navigation`. Those copies are ours to edit and style — nothing important
3265
- is hidden inside `node_modules`.
3826
+ `npx nera-navigation`. Today `npx nera add <name>` runs that command for you, in the
3827
+ same step as the install and the copy of the plugin's default config. Those copies
3828
+ are ours to edit and style — nothing important is hidden inside `node_modules`.
3266
3829
 
3267
3830
  ## Content is just Markdown
3268
3831
 
@@ -3302,3 +3865,409 @@ reading at nera.js.org.
3302
3865
  That's the entire stack: Markdown in, static HTML out, plugins for the rest. If
3303
3866
  you've read the other tutorials in this section, you've now seen every piece of it
3304
3867
  in isolation — this is just all of them together.
3868
+
3869
+ # Use and customise a theme
3870
+
3871
+ Source: https://nera.js.org/tutorials/use-a-theme.html
3872
+
3873
+ A Nera theme is an npm package: layouts, page types, partials, a stylesheet
3874
+ and a set of design tokens. Your site does not copy it. It installs the
3875
+ package and puts a file of its own next to it only where it wants something
3876
+ different. Every other file still comes from the package, so `npm update`
3877
+ keeps bringing the theme's fixes, like a child theme in WordPress.
3878
+
3879
+ This tutorial uses `@nera-static/theme-business`, the theme of the business
3880
+ and portfolio starters. You change a colour, add a few CSS rules, replace one
3881
+ partial, update the theme, and add a theme to a site that has none. Every
3882
+ command and output below was run in a fresh site with theme-business 1.0.3,
3883
+ `@nera-static/nera` 1.28.0 and `@nera-static/core` 4.18.3.
3884
+
3885
+ ## 1. Start a site with a theme
3886
+
3887
+ ```bash
3888
+ npx @nera-static/nera new my-site --theme business
3889
+ cd my-site
3890
+ ```
3891
+
3892
+ ```text
3893
+ 📦 Creating a new Nera site in …/my-site...
3894
+ ✓ Configured project as "my-site"
3895
+ ✓ Using theme "business" (@nera-static/theme-business)
3896
+ • pages/imprint.md and pages/privacy.md are placeholders: link them from the theme's layout (theme-blog and theme-business take `footer_links` in config/theme.yaml), or `nera build --check` keeps warning legal-imprint-link and legal-privacy-link.
3897
+ ```
3898
+
3899
+ `--theme business` does two things. It adds the package to `package.json`:
3900
+
3901
+ ```json
3902
+ "dependencies": {
3903
+ "@nera-static/nera": "^1.28.0",
3904
+ "@nera-static/theme-business": "^1.0.3"
3905
+ }
3906
+ ```
3907
+
3908
+ and it names the theme in `config/app.yaml`:
3909
+
3910
+ ```yaml:config/app.yaml
3911
+ theme: business
3912
+ ```
3913
+
3914
+ `business` is short for `@nera-static/theme-business`. The site gets no
3915
+ layout of its own: `theme/` holds only an empty `theme/assets/`, and every
3916
+ view comes from the package in `node_modules/`.
3917
+
3918
+ Want sample pages for services, opening hours and contact as well? The
3919
+ business starter brings the same theme with them:
3920
+ `npx @nera-static/nera new my-site --starter business`.
3921
+
3922
+ ## 2. Make the first build clean
3923
+
3924
+ Build with the output checks:
3925
+
3926
+ ```bash
3927
+ npx nera build --check
3928
+ ```
3929
+
3930
+ ```text
3931
+ public/imprint.html
3932
+ :44 warning page has more than one `<h1>` — one main heading per page keeps its outline clear; keep one and make the others `<h2>` (WCAG 1.3.1, best practice) (on 3 pages, e.g. public/imprint.html, public/index.html, public/privacy.html) a11y-h1
3933
+ :33 warning page has no link whose text names the imprint (Impressum, Imprint, Legal notice) — it should be easy to find and directly reachable from every page; link it from the layout, such as in the footer, or, if it is linked under another name, set `legal.imprint` in config/validate.yaml (§ 5 DDG) (on 3 pages, e.g. public/imprint.html, public/index.html, public/privacy.html) legal-imprint-link
3934
+ :33 warning page has no link whose text names the privacy policy (Datenschutz, Privacy, Data protection) — it should be easy to find and directly reachable from every page; link it from the layout, such as in the footer, or, if it is linked under another name, set `legal.privacy` in config/validate.yaml (Art. 13 DSGVO) (on 3 pages, e.g. public/imprint.html, public/index.html, public/privacy.html) legal-privacy-link
3935
+
3936
+ 0 error(s), 3 warning(s)
3937
+ ```
3938
+
3939
+ Both come from the scaffolded pages, not from the theme:
3940
+
3941
+ - The theme renders the page's `title` as its one `<h1>`, so a page's
3942
+ Markdown starts at `##`. Delete the `# Welcome to Nera`, `# Imprint` and
3943
+ `# Privacy` lines from the three pages.
3944
+ - The footer links the legal pages you list. Create the site's own
3945
+ `config/theme.yaml`:
3946
+
3947
+ ```yaml:config/theme.yaml
3948
+ footer_links:
3949
+ - label: Imprint
3950
+ href: /imprint.html
3951
+ - label: Privacy
3952
+ href: /privacy.html
3953
+ ```
3954
+
3955
+ Build again:
3956
+
3957
+ ```text
3958
+ ✓ No problems found.
3959
+ ```
3960
+
3961
+ The footer now carries:
3962
+
3963
+ ```html
3964
+ <nav class="site-footer__legal" aria-label="Legal"><a href="/imprint.html">Imprint</a><a href="/privacy.html">Privacy</a></nav>
3965
+ ```
3966
+
3967
+ Replace the two placeholder pages with your own texts before you publish.
3968
+
3969
+ ## 3. How a theme and your site share the work
3970
+
3971
+ Nera looks for every view and every asset in two places, your site first:
3972
+
3973
+ | what | your site | the theme package |
3974
+ |---|---|---|
3975
+ | views | `theme/views/<path>` | `node_modules/@nera-static/theme-business/views/<path>` |
3976
+ | assets | `theme/assets/<path>` | `node_modules/@nera-static/theme-business/assets/<path>` |
3977
+ | settings | `config/theme.yaml` | the package's `config/theme.yaml` |
3978
+
3979
+ A file in your site wins over the theme's file **of the same path**, and only
3980
+ that one file. Everything you do not override comes from the package. Assets
3981
+ are copied theme first, then your site's, so `public/` ends up with both, and
3982
+ yours on top. Your `config/theme.yaml` is merged key by key over the theme's
3983
+ defaults: you set only what you change (lists such as `footer_links` are
3984
+ replaced as a whole).
3985
+
3986
+ The theme's README has a table of what to change where. From cheapest to
3987
+ most expensive:
3988
+
3989
+ | to change | do this | you keep theme updates for |
3990
+ |---|---|---|
3991
+ | a colour, a font, a width | a token in `config/theme.yaml` | everything |
3992
+ | a few CSS rules | `theme/assets/css/custom.css` + `extra_css` | everything |
3993
+ | one partial or page type | copy it to `theme/views/<same path>` | every other file |
3994
+ | the whole page shell | override `layouts/layout.pug` | page types, partials, CSS |
3995
+
3996
+ Sections 4 to 6 go down this table.
3997
+
3998
+ ## 4. Change a colour
3999
+
4000
+ Every token in the theme's `config/theme.yaml` becomes a CSS custom property:
4001
+ `tokens.color.accent` becomes `--theme-color-accent`. Change the accent (links,
4002
+ buttons, the top rule) to a dark teal and give the focus outline the old rust
4003
+ colour:
4004
+
4005
+ ```yaml:config/theme.yaml
4006
+ tokens:
4007
+ color:
4008
+ accent: '#1c5f74'
4009
+ focus: '#a1400f'
4010
+ footer_links:
4011
+ - label: Imprint
4012
+ href: /imprint.html
4013
+ - label: Privacy
4014
+ href: /privacy.html
4015
+ ```
4016
+
4017
+ After `npx nera build`, the `<style>` the theme writes into every page's
4018
+ `<head>` carries your values next to the defaults you did not touch:
4019
+
4020
+ ```html
4021
+ <style>
4022
+ :root {
4023
+ --theme-color-bg: #fbf2e3;
4024
+ --theme-color-surface: #f1e0c3;
4025
+ --theme-color-text: #3b2314;
4026
+ --theme-color-muted: #6e4b2e;
4027
+ --theme-color-accent: #1c5f74;
4028
+ --theme-color-accent-text: #ffffff;
4029
+ --theme-color-border: #dcc6a3;
4030
+ --theme-color-focus: #a1400f;
4031
+ …
4032
+ }
4033
+ </style>
4034
+ ```
4035
+
4036
+ Keep the contrast when you change colours: the accent is text on the page
4037
+ background and on cards, and the background of buttons. `#1c5f74` reaches
4038
+ 6.4:1 on the background, 5.5:1 on the card colour and 7.1:1 under white
4039
+ button text, all above the 4.5:1 that WCAG asks for. The theme's README lists
4040
+ every token and every colour pair it checks.
4041
+
4042
+ ## 5. Add your own CSS
4043
+
4044
+ For rules the tokens do not cover, add a stylesheet of your own and let the
4045
+ theme link it. Put it into `theme/assets/css/custom.css`; the rule styles a
4046
+ line you will add in the next section:
4047
+
4048
+ ```css:theme/assets/css/custom.css
4049
+ .page-kicker {
4050
+ margin: 0 0 0.25rem;
4051
+ color: var(--theme-color-accent);
4052
+ font-size: 0.875rem;
4053
+ font-weight: 600;
4054
+ letter-spacing: 0.08em;
4055
+ text-transform: uppercase;
4056
+ }
4057
+ ```
4058
+
4059
+ and list it under `extra_css` in `config/theme.yaml`:
4060
+
4061
+ ```yaml:config/theme.yaml
4062
+ extra_css:
4063
+ - /css/custom.css
4064
+ ```
4065
+
4066
+ The theme links it after its own stylesheet and the token `<style>`, so your
4067
+ rules win:
4068
+
4069
+ ```html
4070
+ <link rel="stylesheet" href="/css/theme.css">
4071
+ <style>
4072
+ …
4073
+ </style>
4074
+ <link rel="stylesheet" href="/css/custom.css">
4075
+ ```
4076
+
4077
+ `public/css/` now holds both `theme.css` (from the package) and `custom.css`
4078
+ (from your site). Use the tokens (`var(--theme-color-accent)`) rather than
4079
+ copied colour values, so a change in section 4 reaches your rules too. The
4080
+ theme lists its public class names in its README; those are the ones that
4081
+ stay stable across minor and patch releases.
4082
+
4083
+ Do not override `theme/assets/css/theme.css` itself: your copy would replace
4084
+ the theme's whole stylesheet, and its fixes would stop reaching you.
4085
+
4086
+ ## 6. Override one partial
4087
+
4088
+ Now change markup. The page header of every page except the front page
4089
+ lives in the partial `partials/page-header.pug`. Copy it from the package to
4090
+ the same path in your site:
4091
+
4092
+ ```bash
4093
+ mkdir -p theme/views/partials
4094
+ cp node_modules/@nera-static/theme-business/views/partials/page-header.pug theme/views/partials/
4095
+ ```
4096
+
4097
+ and add a small line above the title, read from a new `kicker` frontmatter
4098
+ key:
4099
+
4100
+ ```pug:theme/views/partials/page-header.pug
4101
+ //- Overrides the theme's partials/page-header.pug: adds a kicker line
4102
+ //- above the page title, from the page's `kicker` frontmatter.
4103
+ header.page__header
4104
+ if meta.kicker
4105
+ p.page-kicker= meta.kicker
4106
+ h1.page__title= meta.title || app.name
4107
+ if meta.lead
4108
+ p.page__lead= meta.lead
4109
+ ```
4110
+
4111
+ The class is your own, `page-kicker`, not a name inside the theme's
4112
+ `page__…` block: a later theme release could add a `page__kicker` of its own.
4113
+ Use it on a page:
4114
+
4115
+ ```markdown:pages/about.md
4116
+ ---
4117
+ layout: pages/default.pug
4118
+ title: About us
4119
+ kicker: Since 1998
4120
+ lead: A small bakery in the middle of Berlin.
4121
+ description: Who we are and how we bake
4122
+ ---
4123
+ ## Our story
4124
+
4125
+ We bake every loaf by hand.
4126
+ ```
4127
+
4128
+ `npx nera build` renders `public/about.html` with your header:
4129
+
4130
+ ```html
4131
+ <header class="page__header">
4132
+ <p class="page-kicker">Since 1998</p>
4133
+ <h1 class="page__title">About us</h1>
4134
+ <p class="page__lead">A small bakery in the middle of Berlin.</p>
4135
+ </header>
4136
+ ```
4137
+
4138
+ A page without `kicker` renders as before. Every other view, the layout, the
4139
+ footer, the page types, still comes from the package: you took over one file,
4140
+ not the theme.
4141
+
4142
+ A theme often prepares such places for you. theme-business ships empty
4143
+ partials, its *seams*, for plugin output: `partials/head-extra.pug` at the end
4144
+ of `<head>`, `partials/nav-main.pug` in the header navigation,
4145
+ `partials/footer-extra.pug` in the footer and a few more, listed in its
4146
+ README. Overriding a seam costs nothing, since there is no theme markup in it
4147
+ to miss out on. For a page type of your own, put a new file under
4148
+ `theme/views/pages/` that `extends ../layouts/layout.pug`; the README shows
4149
+ one.
4150
+
4151
+ ## 7. Updates keep coming
4152
+
4153
+ Update the theme the same way as Nera itself:
4154
+
4155
+ ```bash
4156
+ npx nera update
4157
+ ```
4158
+
4159
+ ```text
4160
+ 🔄 Updating Nera packages: @nera-static/nera, @nera-static/theme-business
4161
+ ```
4162
+
4163
+ `nera update` runs `npm update` for every `@nera-static/` package in
4164
+ `package.json`, the theme included. Like `npm update`, it stays within each
4165
+ package's range, so a new major version of the theme is never installed
4166
+ behind your back. `npm ls` shows the version you have:
4167
+
4168
+ ```bash
4169
+ npm ls @nera-static/theme-business
4170
+ ```
4171
+
4172
+ ```text
4173
+ my-site@1.0.0 …/my-site
4174
+ └── @nera-static/theme-business@1.0.3
4175
+ ```
4176
+
4177
+ An update replaces the files in `node_modules/`, never the ones in your
4178
+ `theme/`. That cuts both ways:
4179
+
4180
+ - Your tokens, `custom.css` and `page-header.pug` survive every update.
4181
+ - Your `page-header.pug` no longer receives the theme's changes to that
4182
+ file. Everything else does.
4183
+
4184
+ After an update, compare each file you override with the theme's new
4185
+ version and take over what you want:
4186
+
4187
+ ```bash
4188
+ diff node_modules/@nera-static/theme-business/views/partials/page-header.pug theme/views/partials/page-header.pug
4189
+ ```
4190
+
4191
+ ```text
4192
+ 1,2c1,2
4193
+ < //- The page header of every page type but home (§S3.1 "Header"): the page's
4194
+ < //- one <h1> and its lead.
4195
+ ---
4196
+ > //- Overrides the theme's partials/page-header.pug: adds a kicker line
4197
+ > //- above the page title, from the page's `kicker` frontmatter.
4198
+ 3a4,5
4199
+ > if meta.kicker
4200
+ > p.page-kicker= meta.kicker
4201
+ ```
4202
+
4203
+ Here the only differences are yours. The theme follows semantic versioning
4204
+ over its view paths, tokens, settings and public classes: a minor or patch
4205
+ release keeps your overrides working, and a major one says in its CHANGELOG
4206
+ what to change. The fewer files you override, the less there is to compare.
4207
+
4208
+ ## 8. Add a theme to an existing site
4209
+
4210
+ A site created without `--theme` has its own layout, scaffolded by
4211
+ `nera new`. Install the theme and name it in `config/app.yaml`:
4212
+
4213
+ ```bash
4214
+ npm install @nera-static/theme-business
4215
+ ```
4216
+
4217
+ ```yaml:config/app.yaml
4218
+ theme: business
4219
+ ```
4220
+
4221
+ `nera validate` then points at the two scaffolded views that are in the way:
4222
+
4223
+ ```text
4224
+ theme/views/layouts/layout.pug
4225
+ :1 warning the `nera new` starter file hides the theme's own layouts/layout.pug — delete it to use the theme's, or remove the `nera:scaffold-default` line to keep it on purpose theme-shadowed
4226
+ theme/views/pages/default.pug
4227
+ :1 warning the `nera new` starter file hides the theme's own pages/default.pug — delete it to use the theme's, or remove the `nera:scaffold-default` line to keep it on purpose theme-shadowed
4228
+
4229
+ 0 error(s), 2 warning(s)
4230
+ ```
4231
+
4232
+ They have the same paths as two of the theme's views, so by the rule of
4233
+ section 3 they would win, and the theme would never show. Their first line,
4234
+ `//- nera:scaffold-default`, marks them as untouched starter files. Delete
4235
+ them:
4236
+
4237
+ ```bash
4238
+ rm theme/views/layouts/layout.pug theme/views/pages/default.pug
4239
+ npx nera validate
4240
+ ```
4241
+
4242
+ ```text
4243
+ ✓ No problems found.
4244
+ ```
4245
+
4246
+ If you changed one of them and want to keep it, remove its
4247
+ `nera:scaffold-default` line instead: the file is then a deliberate override
4248
+ and the warning goes away. Then fix the headings and the footer links as in
4249
+ section 2.
4250
+
4251
+ A page renders with the theme's page type of the same name as its `layout`.
4252
+ theme-business has `pages/home.pug`, `default.pug`, `contact.pug`,
4253
+ `list.pug` and `gallery.pug`; a page whose `layout` names a view neither your
4254
+ site nor the theme has fails `nera validate` with `layout-unresolved`, which
4255
+ names both places it looked.
4256
+
4257
+ ## 9. Build your own theme
4258
+
4259
+ A theme of your own is an npm package with the same layout: `views/`,
4260
+ `assets/` and `config/theme.yaml`. `@nera-static/theme-example` is the
4261
+ smallest one, kept small to copy: its README's section
4262
+ [Using it as a blueprint for your own theme](https://github.com/seebaermichi/nera-theme-example#using-it-as-a-blueprint-for-your-own-theme)
4263
+ walks through renaming the package, the fields Nera needs to find it, and the
4264
+ seams that let a site extend it without forking. theme-business shows the
4265
+ same ideas at full size: tokens, seams and a documented contract.
4266
+
4267
+ ## Next
4268
+
4269
+ The [theme-business README](https://github.com/seebaermichi/nera-theme-business#readme)
4270
+ has every token, setting, seam and public class. The plugin tutorials, such
4271
+ as [Custom navigation](https://nera.js.org/tutorials/custom-navigation.html), show how to publish
4272
+ a plugin's templates; with theme-business you include them from a seam, as
4273
+ its README shows for each plugin it supports.