Problem/Motivation

When generating the llms.txt file from Drupal menus, parent items configured with the <nolink> route (often used as non-clickable containers for submenus) are currently rendered as Markdown links with an empty URL.

For example, given a menu structure where "Menu Item 1" and "Menu Item 2" are parent containers without links:

Menu No links

Current output: The module renders these items with empty parentheses ():

File no links

Expected output: Since these items are structural labels and do not point to any resource, they should be rendered as plain text in the Markdown list to provide a cleaner structure for LLMs, avoiding the syntax of broken or empty links.

## Main Menu
- Menu Item 1
  - [Menu Item A](http://example.com)
- Menu Item 2
  - [Menu Item B](http://example.com)
- [Menu Item C](http://example.com)

Proposed resolution

Update the menu tree rendering logic to check if a menu link is routed to <nolink>. If so, render the item title as a plain string instead of wrapping it in the []() Markdown link syntax.

Issue fork llms_txt-3572524

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

albeorte created an issue. See original summary.

albeorte’s picture

Issue summary: View changes
mxr576’s picture

Thanks for raising this issue. Would you be able to try fixing the problem and also extend the related test with an additional test case?

albeorte’s picture

Assigned: Unassigned » albeorte

I will try to have the MR ready for review in the next few days.

albeorte’s picture

Assigned: albeorte » Unassigned
Status: Active » Needs review

A merge request has been created and test coverage has been extended with this case.

Ready to check!

  • mxr576 committed 30bb6d36 on 1.x authored by albeorte
    #3572524: Render <nolink> menu items as plain text instead of empty...
mxr576’s picture

Status: Needs review » Fixed

Thanks! Simplifed test coverage and merged it.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mxr576’s picture

Status: Fixed » Closed (fixed)
albeorte’s picture

@mxr576, please, since it has been merged.

Can you release the version associated with this change?

mxr576’s picture

Thanks for raising the question, I have already checked when I merged this fix and this is the only commit since the latest tagged version, I would like to check what is in the pipeline and preferably create a release with at least one more commit.

mxr576’s picture

https://www.drupal.org/project/llms_txt/releases/1.0.6 released. Thanks for the patience.