@builder/web/site

@builder/web/site provides compile-time helpers for static site URLs. It uses the structural site root rather than reading the browser or the current page.

Choose the explanation level: Static site URLs

Static site URLs

@builder/web/site builds static links at compile time. Import it explicitly in a .moth file to use the site root and add site-relative paths.

@builder/web/site

home #= site.root
guide #= [site.url:docs/getting-started/]
[:home=[home] guide=[guide]]

Don't start the suffix with /. The root follows the project's configured origin, so the guide renders under /moth/docs/getting-started/ when the origin is /moth.

Unlike site.url, @builder/web/page's page.url() reads the live browser address at runtime. For the package contract see @builder/web/site advanced.

@builder/web/site belongs to the Builder origin family with MothSource backing. It publishes through a directly contained @package.moth. See Package origins and backing for the package model. It requires an explicit @builder/web/site dependency and isn't in the implicit scope of .mtf files.

Static URLs

site.root is a compile-time String containing the structural site root. It always ends with / and follows the consuming project's configured origin when the builder renders the page. site.url appends its slot to that root.

Pass a site-relative suffix without a leading /. This is a caller convention, not a checked rule. url concatenates the two strings, so a leading / produces /moth//docs/ under origin = "/moth". Under the default origin it produces //docs/, which browsers read as a link to a host named docs.

The helper composes strings without validating routes, encoding or normalising paths. It doesn't inspect the current page or browser. Use @builder/web/page for live browser state. In particular, site.url builds links at compile time while page.url() reads the current browser address at runtime.