Skip to main content

URLs and Routing


This page explains how Hugo determines the URL for each page. Get URL management right from the start. Broken links damage a site more than almost anything else, so plan your approach early.

Default URL Rules

Hugo automatically generates a URL based on the file path under content/:

content/posts/my-first-post.md   →   /posts/my-first-post/
content/about.md                 →   /about/

The default URL rules already fit most practical use cases, unless you have a clear, specific need.

To change how URLs are generated, configure permalinks in hugo.yaml:

[permalinks]
  posts = '/:year-:month-:slugorcontentbasename/'

The setting above makes URLs under posts include the year and month, for example:

content/posts/my-first-post.md   →   /2026-08-my-first-post/

For the full configuration reference, see the permalinks documentation.

Manually Setting a Single Page's URL

To change the URL of just one post, add slug to that post's front matter:

---
title: 'My Post'
slug: 'custom-slug'
---

This changes only the final segment of the URL to custom-slug. To change the preceding path as well, use url to set the full path instead, for example url: '/blog/post1'.

Accessibility settings

Font size