Statac

Problems explained

Field written two ways

warning A warning says what Statac did instead, and the build goes on.

One of your own fields is written with a dot in its name on one page, such as book.author:, and nested on another, as book: with author: beneath it. To YAML these are two different fields.

What you’ll see

warning  Field written two ways: `book.author` is also nested under `book`
  Nest it under `book`, so templates read it as `page.book.author`.
  More: https://statac.dev/e/field-written-two-ways/

In the terminal the message also names the file and line where there is one, and marks the exact text.

Why Statac warns

A template asking for page.book.author finds the nested one and misses the other, so some pages would show nothing there. Statac keeps both as you wrote them and tells you, showing where the nested one is.

How to fix it

Nest the field everywhere, so templates read it one way.

Example

In content/post-1.md:

---
title: Post 1
book.author: Author 1
---

In content/post-2.md, the same field is nested. Nest it in post-1.md too:

---
title: Post 1
book:
  author: Author 1
---

Its name

Namefield-written-two-ways
In the terminalstatac explain field-written-two-ways
To stop showing itquiet: [field-written-two-ways] in statac.yaml, once you have understood it. Statac still counts it.

Something unclear or wrong? Open an issue on GitHub.