The navigation bar at the top of every page is controlled by a single file: _data/top-nav.yml. This guide shows you how to customize it for your site.
_data/ foldertop-nav.ymlThe navigation file uses YAML syntax, which relies on indentation to show hierarchy. Here’s what a basic dropdown menu looks like:
- title: "Getting Started"
items:
- title: "Creating your site"
url: "/getting-started/"
- title: "Understanding Folders"
url: "/getting-started/understanding-folders"
What this creates:
Use this for grouping related pages together:
- title: "Navigation"
items:
- title: "Overview"
url: "/navigation/"
- title: "Cards"
url: "/navigation/cards"
- title: "Left Navbar Demo"
url: "/navigation/nav-left-demo"
Key points:
title is what appears in the menu baritems: starts the list of links (note the colon!)title (link text) and url (destination)- title under items must be indented exactly 4 spacesUse this for standalone pages:
- title: "FAQs"
url: "/faqs"
This creates: A single link labeled “FAQs” that goes directly to /faqs (no dropdown menu)
Visual separators inside dropdown menus help organize long lists:
- title: "Content & Design"
items:
- title: "Typography"
url: "/content-design/typography"
- title: "Images"
url: "/content-design/images"
- divider: true
- title: "Editing Locally"
url: "/getting-started/editing-locally"
What this creates:
The blank lines before and after - divider: true are optional but make the file easier to read.
Let’s add “Bibliography” to the “Getting Started” menu:
Before:
- title: "Getting Started"
items:
- title: "Creating your site"
url: "/getting-started/"
After:
- title: "Getting Started"
items:
- title: "Creating your site"
url: "/getting-started/"
- title: "Bibliography"
url: "/bibliography"
Remember: Match the indentation exactly (4 spaces for items under items:)
Add this to your top-nav.yml file:
- title: "Research"
items:
- title: "Projects"
url: "/projects"
- title: "Publications"
url: "/publications"
- title: "Datasets"
url: "/datasets"
Position matters: The menu will appear in the order you list items in the file. If you want “Research” to appear third, make sure it’s the third item.
- title: "About"
url: "/about"
Simple! Just title and url, no items:.
Just delete the entire section. To remove “ScrollStories”:
Delete this entire block:
- title: "ScrollStories"
items:
- title: "Overview"
url: "/scrollstories"
- title: "Seedling Essay"
url: "/scrollstories/seedling"
# ... and all other items
Just change the title:
Before:
- title: "FAQs"
url: "/faqs"
After:
- title: "Help"
url: "/faqs"
The link stays the same; only the display text changes.
For pages on your site (most common):
url: "/about" # Correct - starts with /
url: "/guides/tutorial" # Correct - starts with /
For external websites:
url: "https://github.com/fredgibbs/xanthan" # Full URL with https://
Common mistakes:
url: "about" # WRONG - missing the /
url: "about.md" # WRONG - don't include .md
url: "about.html" # WRONG - don't include .html
If your file structure looks like this:
your-repo/
about.md
guides/
tutorial.md
projects/
index.md
Your URLs should be:
url: "/about" # for about.md
url: "/guides/tutorial" # for guides/tutorial.md
url: "/projects/" # for projects/index.md
YAML uses spaces (not tabs) for indentation. Each level must be indented exactly the same amount.
Correct:
- title: "Menu"
items:
- title: "Link"
url: "/page"
Wrong (inconsistent indentation):
- title: "Menu"
items:
- title: "Link" # Only 3 spaces - will break!
url: "/page"
Use quotes for titles and URLs:
title: "Getting Started" # Correct
url: "/guides/tutorial" # Correct
Why? Some special characters (like colons) can break YAML if not quoted. Quotes always work, so it’s safer to use them consistently.
After every colon, add a space:
title: "Menu" # Correct - space after colon
items: # Correct - space after colon
- title:"Link" # WRONG - no space after colon
After editing top-nav.yml:
Navigation completely disappears:
items: should be indented 4 spacestitle: and url: has a space after the colonLink doesn’t work (404 error):
/.md or .html in the URLMenu looks weird:
items: with a colonurl: not items:Here’s a simple, complete example you can adapt:
- title: "About"
url: "/about"
- title: "Research"
items:
- title: "Overview"
url: "/research/"
- title: "Current Projects"
url: "/research/current"
- title: "Publications"
url: "/publications"
- title: "Teaching"
items:
- title: "Courses"
url: "/teaching/courses"
- title: "Advising"
url: "/teaching/advising"
- title: "Contact"
url: "/contact"
This creates:
If your pages are organized in nested folders:
your-repo/
research/
current/
project-1.md
project-2.md
Your URL structure reflects this:
- title: "Research"
items:
- title: "Project 1"
url: "/research/current/project-1"
- title: "Project 2"
url: "/research/current/project-2"
Remember: The URL follows the folder path, minus the .md extension.
Navigation not working?
top-nav.yml contentStill stuck?
top-nav.yml in the Xanthan repository