Problem/Motivation

The Markdownify module currently generates Markdown versions of Drupal content based on entity routes. However, it does not support generating Markdown output using the path alias of an entity.

For example, if a node's path alias is /en/articles/give-your-oatmeal-the-ultimate-makeover, users should be able to access the Markdown version at /en/articles/give-your-oatmeal-the-ultimate-makeover.md. This feature is essential for maintaining consistency with human-readable URLs and for providing user-friendly, SEO-compliant access to Markdown content.


Steps to reproduce

  1. Enable the Markdownify module.
  2. Create a node with a path alias (e.g., /en/articles/example-article).
  3. Try accessing the Markdown version of the content using the path alias and .md (e.g., /en/articles/example-article.md).
  4. Observe that the request does not return the expected Markdown output.

Proposed resolution

Add support for generating Markdown output using entity path aliases. When a .md extension is appended to a path alias, the module should resolve the alias to its corresponding entity and return the Markdown version of the content.

Key considerations:

  • Ensure that .md works seamlessly with both canonical URLs (e.g., /node/1.md) and path aliases.
  • Maintain backward compatibility with existing routes and request patterns.

Remaining tasks

  1. Update the routing logic in the module to resolve path aliases for .md extensions.
  2. Test the implementation with various entities (e.g., nodes, taxonomy terms) that support path aliases.
  3. Update module documentation to include examples of using .md with path aliases.
  4. Provide automated tests to ensure compatibility and prevent regressions.

User interface changes

No direct UI changes are anticipated, as this functionality extends the module's routing logic.


API changes

None. The changes will enhance existing functionality without altering the API.


Data model changes

None. The proposed changes operate at the routing and rendering layers and do not affect the data model.


Comments

i'mbatman created an issue. See original summary.

christophweber’s picture

Priority: Normal » Major
christophweber’s picture

This is an important feature and will support llms.txt output where a .md extension added to the canonical URL is the expected way to obtain MD output.

  • i'mbatman committed aea426be on main
    Issue #3512362: Enhance Markdownify module with path alias support and...
imbatman’s picture

This feature is now fully supported and introduced in Markdownify 1.0.0-rc3.

See:
1. https://www.drupal.org/project/markdownify#six-ways-to-access-markdown-c...
2. https://git.drupalcode.org/project/markdownify/-/blob/1.0.0-rc3/README.m...

Thank you to everyone who contributed to the implementation of this module!

imbatman’s picture

Status: Active » Fixed
christophweber’s picture

Assigned: imbatman » Unassigned
Status: Fixed » Closed (fixed)

Tested and works as designed.