Add Support for .md URLs Using Path Aliases in the Markdownify Module

Created on 12 March 2025, 28 days ago

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.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡΄Colombia i'mbatman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024