R04
Warning
Routes
R04 — A relative URL on a nested route
"images/x.png" is fetched relative to the page's address, so on /blog/post it is /blog/images/x.png. Written from the root, "/images/x.png", it is the same file on every page.
What the compiler said
warning[R04]: `src: "images/cover.png"` is relative, so on `/blog/first` it is fetched from `/blog/images/cover.png` --> src/App.wf:3:5 | 3 | Image(src: "images/cover.png", alt: "") | ^^^^^ = help: Write it from the site's root: `"/images/cover.png"` = docs: https://webfluent.monzeromer.dev/errors/R04
The fix
Broken
page Post(path: "/blog/first", title: "T", description: "D") {
Heading("First post").h1
Image(src: "images/cover.png", alt: "")
}
Fixed
page Post(path: "/blog/first", title: "T", description: "D") {
Heading("First post").h1
Image(src: "/images/cover.png", alt: "")
}
Write it from the site's root: "/images/cover.png".
Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).
Why this rule exists
Warning.
lints may lower it:
"lints": { "R04": "off" }
// wf-allow(R04)