pub struct MD057Config {
pub absolute_links: AbsoluteLinksOption,
pub compact_paths: bool,
pub self_referential_links: bool,
pub search_paths: Vec<String>,
pub roots: Vec<String>,
pub check_frontmatter: bool,
pub ignore_frontmatter_fields: Vec<String>,
}Expand description
Configuration for MD057 (relative link validation)
This rule validates that relative links point to existing files.
Fields§
§absolute_links: AbsoluteLinksOptionHow to handle absolute links (paths starting with /)
- “ignore” (default): Skip validation for absolute links
- “warn”: Report a warning for absolute links
- “relative_to_docs”: Resolve relative to MkDocs docs_dir and validate
- “relative_to_roots”: Resolve relative to one or more configured root directories
compact_paths: boolWarn when relative links contain unnecessary path traversal.
When enabled, ../sub_dir/file.md from within sub_dir/ warns
and suggests the shorter equivalent file.md.
self_referential_links: boolWarn when a relative link points at the file it is written in.
Following such a link reloads the page the reader is already on. When
the link carries a fragment, file.md#section from within file.md
warns and suggests #section, which reaches the same heading without
the reload. A link to the whole file has no equivalent shorter form, so
it is reported without a fix.
search_paths: Vec<String>Additional directories to search when a relative link is not found relative to the file’s directory.
Paths are resolved relative to the project root (where .rumdl.toml or
pyproject.toml is found), or relative to the current working directory.
For Obsidian users: the attachment folder is auto-detected from
.obsidian/app.json when flavor = "obsidian" is set, so this option
is typically not needed. Use it for custom setups or non-Obsidian tools.
Example:
[MD057]
search-paths = ["assets", "images", "attachments"]roots: Vec<String>Root directories used when absolute-links = "relative_to_roots".
Absolute links are resolved against each configured root in order, then against the project root as an implicit fallback. The first root under which the target file exists passes the check. A warning is emitted only when no resolution finds the file.
The implicit project-root fallback supports both link styles in the same
project without extra configuration: /foo.md (relative to a configured
root) and /content/en/foo.md (literal path from the project root).
Paths are resolved relative to the project root when not absolute. Trailing slashes are normalized automatically.
When roots is empty, absolute links are validated against the project
root only — useful for single-root projects where every absolute link
resolves directly from the project root.
Example:
[MD057]
absolute-links = "relative_to_roots"
roots = ["content/en", "content/zh-cn"]check_frontmatter: boolAlso check path-shaped values in the document’s frontmatter.
Off by default, because frontmatter has no syntax marking a value as a link: a path-shaped value is only a guess at one. Static-site generators also resolve frontmatter paths from the site root rather than the document’s own directory, so checking them like body links reports working paths as broken.
Enable it for projects whose frontmatter paths really are relative to
the document, and use ignore-frontmatter-fields for the keys that are
not.
Example:
[MD057]
check-frontmatter = true
ignore-frontmatter-fields = ["image", "cover"]ignore_frontmatter_fields: Vec<String>Top-level frontmatter keys whose values are not checked. Matched
case-insensitively. A parent key excludes its whole subtree. Applies
only when check-frontmatter is enabled.
Trait Implementations§
Source§impl Clone for MD057Config
impl Clone for MD057Config
Source§fn clone(&self) -> MD057Config
fn clone(&self) -> MD057Config
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more