Drupal 8 tip of the day : check menu links consistency

Submitted by Frederic Marand on

Excerpt from a Drupal 8 menu links treeOne of the interesting aspects of the revamped menu/links system in Drupal 8 is the fact that menu links are now in easily parseable YAML files, the "(module).links.menu.yml" in each module, in which each menu link can be bound to its parent link, hopefully producing a tree-like structure.

This provides an easy way to check consistency of the links graph, by ensuring links newly defined in your shiny custom module are linked to a valid parent link path, to help with the overall navigability of the site. This can be checked using the Tooling module, and its Drush command tolt, like in this example.

  • clone the module to (yoursite)/modules/tooling
  • ensure Drush is working on your site
  • ensure GraphViz (the dot command) is working on your system
  • drush tolt | dot -Tsvg > mysite.svg

That's it: the mysite.svg file should now contain the tree of your menu links, with all orphan links flagged in orange for you to examine, like in the image.