Menu Configuration
The Sans theme features a customizable main navigation menu that provides site-wide navigation. This guide covers all aspects of menu configuration and customization.
Menu System Overview
The theme implements a single main navigation menu that appears consistently across all pages. Menu configuration is managed through the config/menus.toml file, providing centralized control over navigation structure.
Basic Configuration
Configuration File Location
Menu settings are stored in:
your-hugo-site/config/menus.toml
Menu Entry Structure
Each menu item follows this basic structure:
| |
Core Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Display text shown in navigation |
| pageRef | string | No* | Internal page reference (Hugo pages) |
| url | string | No* | Direct URL (files, external links) |
| weight | integer | Yes | Display order (lower values appear first) |
| params | object | No | Additional parameters (e.g., target attribute) |
Note: Either pageRef or url must be specified, but not both.
Menu Item Types
1. Homepage Link
Link to the site’s root page:
| |
2. Taxonomy Pages
Link to automatically generated taxonomy list pages:
| |
3. Individual Pages
Link to specific content pages:
| |
Path Structure: The pageRef should match your content directory structure:
- Content file:
content/pages/about.md - Menu reference:
pageRef = '/pages/about/'
4. Direct File Links
Link directly to files (PDFs, images, downloads):
| |
File Location: Place files in the static directory:
- File path:
static/files/resume.pdf - Menu URL:
url = '/files/resume.pdf'
5. External Links
Link to external websites or resources:
| |
6. Section Links
Link to content sections or subdirectories:
| |
Weight-Based Ordering
Understanding Weight
The weight parameter determines menu item display order using ascending numeric values.
| Weight Value | Position | Best Practice |
|---|---|---|
| Lower numbers | Appear first (left) | Homepage, main sections |
| 10, 20, 30... | Standard increment | Allows easy insertion of new items |
| Higher numbers | Appear last (right) | Secondary links, external resources |
Weight Examples
| |
Result: Menu renders as: Home | Blog | About | Contact Using increments of 10 allows easy insertion:
Advanced Parameters
Opening Links in New Tabs
Use the params object to add HTML attributes:
| |
Security Attributes for External Links
For external links, add security attributes:
| |
Custom CSS Classes
Add custom styling classes to menu items:
| |
Complete Configuration Example
Full Menu Configuration
| |
Responsive Behavior
Mobile Menu
The theme automatically adapts the menu for mobile devices:
- Desktop: Horizontal navigation bar
- Mobile: Hamburger menu or collapsed navigation
- Touch-friendly: Appropriate tap target sizes