I have jekyll read the docs pages. I added a _data\navigation.yml file with weights,…
- User
I have jekyll read the docs pages. I added a _data\navigation.yml file with weights, where do I tell jekyll to use the weights to sort the sidebar?
- Assistant
In Jekyll + Read the Docs theme (typically the jekyll-theme-sphinx-rtd or similar), adding a _data/navigation.yml file does not automatically make Jekyll sort the sidebar by your custom weight fields. Jekyll does not sort data files by default—you must explicitly tell the theme how to sort them. ✅ Where to tell Jekyll to sort using weight Sidebars in Read-the-Docs–style Jekyll themes are usually generated in one of these files: bashCopiar código_includes/nav.html _includes/sidebar.html _includes/toc.html
To use weight, you must edit whichever include builds navigation and add: liquidCopiar código{% assign nav_items = site.data.navigation | sort: "weight" %}
Or, if navigation is nested: liquidCopiar código{% assign nav_sections = site.data.navigation | sort: "weight" %} {% for section in nav_sections %} {% assign items = section.items | sort: "weight" %} ... {% endfor %}
📌 Why it’s necessary Jekyll will load your _data/navigation.yml file, but sorting never happens automatically. The sidebar template must explicitly sort the items before rendering. Example navigation.yml yamlCopiar código- title: Intro url: /intro/ weight: 1