Bind a .md file the same way as any other source file.
Bind and use
@docs/intro content as intro_html
[: [intro_html] ]
The content constant is the rendered HTML string.
Do not include the extension
@docs/intro.md content is rejected. Use @docs/intro content.
Plain Markdown content is bound with the same extensionless source dependency clause syntax as Moth and moth template source assets.
Dependency syntax
@docs/intro
[: [intro.content] ]
A bare namespace clause exposes content as a field. A direct selection binds it directly:
@docs/intro content as intro_html
[: [intro_html] ]
Aliases
Use as to give the bound content a local name. This is the standard form when multiple content files are depended on by the same page.
Insertion into templates and pages
Insert the bound content into a template body. The caller decides where it appears. Bound content does not become a page fragment automatically.
Dependency paths and module visibility
Content dependency clauses follow the same path resolution and module visibility rules as normal source dependency clauses. Both @intro and @docs/intro resolve from the declaring file's owning module root; the latter selects docs/intro below that root. @./... has no supported meaning. Cross-module dependency clauses require the module root's export: block to re-export the content.
No automatic page fragment
Binding a .md file and inserting its content into a template does not create a page fragment. Only direct top-level templates in an entry-selected module root become page fragments.
Explicit extensions are rejected for source content
@docs/intro.md content
This is rejected with MOTH-IMPORT-0024. Use @docs/intro without the .md extension.
The same content as a file value
The explicit-extension spelling that a clause rejects is valid in expression position, where it evaluates to the same rendered content string:
license #= @legal/license.md
Both forms name one compiled file and one content value, and plain Markdown links and images inside the file stay literal and untracked either way. See File values.
Dependency tracking
Bound content participates in normal dependency tracking. The .md file is compiled before the declaring file uses its content constant.
Distinction from resource dependencies
A .md content dependency clause is not a resource reference. It produces a compile-time content #String constant. Markdown links and images inside the file render literal href and src values: they are not resources, and they are not rewritten. Write a Moth file path when a file should become a resource-bearing String and take part in resource output.
Related concepts