Permalink confliction

Hi, I need help for solving confliction on permalink. I mean, I want to control what happens when two pages have the same permalink.
By defalut, Hugo seems to override the older one with newer one without warning.

Basically I set a date and a slug for the posts with filename (, and set my Permalink /:slug.
I need some solution for this, like in these ways:

  1. automatically add some number to newer conflicting permalink. Like renaming /posts/this-is-a-slug/ to /posts/this-is-a-slug-1/
  2. Raise an error when confliction found and abort building pages.

I have set my config.toml as below:

baseURL = ""
languageCode = "en-us"
title = "My New Hugo Site"
theme = "ananke"

  posts = "/:slug/"

  date = ["date", "publishDate", ":filename", "lastmod"]

I searched a lot and found nothing about how to control the conflicting permalinks.
Thank you in advance for helping me.

1 Like

Why not instead set permalink config to filename?

  posts = "/:filename/"

You can’t have two files with the same filename, so as a consequence the generated permalinks should be unique.

That is what I’m planning to do if there is no solution.
I want to avoide it because it makes the url longer :disappointed_relieved:
Thanks anyway

As of v0.55.0, hugo has this flag:

--path-warnings   print warnings on duplicate target paths etc.

IMHO, this should flag should default to on.


Thank you so much! Although Hugo keep bulding and exit with 0, now I know there are duplicate paths. I hope there is a option to abort building if there are warnings.

1 Like