Skip to content

MD054 - Use consistent link and image style

Aliases: link-image-style

What this rule does

Ensures all links and images in your document use the same formatting style for better consistency and readability.

Why this matters

  • Professional appearance: Mixed link styles make documents look disorganized
  • Easier maintenance: Consistent style makes it easier to find and update links
  • Better readability: Readers can quickly recognize and understand link patterns
  • Team consistency: Everyone follows the same linking conventions

Examples

✅ Correct (all inline style)

Check out [our website](https://example.com) for more info.

See the [documentation](https://docs.example.com) for details.

View our ![company logo](https://example.com/logo.png).

✅ Correct (all reference style)

Check out [our website][site] for more info.

See the [documentation][docs] for details.

View our ![company logo][logo].

[site]: https://example.com
[docs]: https://docs.example.com
[logo]: https://example.com/logo.png

❌ Incorrect (mixed styles)

Check out [our website](https://example.com) for more info.

See the [documentation][docs] for details.

View our <https://example.com/contact> page.

[docs]: https://docs.example.com

🔧 Fixed

Check out [our website](https://example.com) for more info.

See the [documentation](https://docs.example.com) for details.

View our [contact page](https://example.com/contact).

Configuration

Configure which link and image styles are allowed in your documents. By default, all styles are allowed. Set a style to false to disallow it.

[MD054]
autolink = true    # Allow <https://example.com>
inline = true      # Allow [text](url) and ![alt](url)
full = true        # Allow [text][ref] with separate [ref]: url definition
collapsed = true   # Allow [text][] with separate [text]: url definition
shortcut = true    # Allow [text] with separate [text]: url definition
url-inline = true  # Allow [https://example.com](https://example.com)
  • autolink: <https://example.com> - Bare URLs in angle brackets
  • inline: [text](url) and ![alt](url) - Direct inline links and images
  • full: [text][ref] - Full reference with separate definition [ref]: url
  • collapsed: [text][] - Collapsed reference (label matches definition)
  • shortcut: [text] - Shortcut reference (just label, definition inferred)
  • url-inline: [https://example.com](https://example.com) - URL as both text and destination

Common configurations

Only allow inline links:

[MD054]
autolink = false
inline = true
full = false
collapsed = false
shortcut = false
url-inline = false

Only allow reference-style links:

[MD054]
autolink = false
inline = false
full = true
collapsed = true
shortcut = true
url-inline = false

Prefer autolinks for bare URLs:

[MD054]
autolink = true
inline = true
full = true
collapsed = true
shortcut = true
url-inline = false  # Disallow [url](url), prefer <url> instead

Automatic fixes

This rule currently does not support automatic fixing. Links and images must be manually updated to match the allowed styles.

Learn more