Dynamic url structure in front matter


Is it possible to define a url in front matter. For e.g

  -- _index.md
  -- post.md

in post.md to have front matter such as

title: "Posts"
description: "Past post"
date: 2022-05-05T13:00:00Z
draft: false
  - /post/:year/:month/:day
  - /post/**

I know aliases is not the correct place for this definition - but is there similar keyword available - if possible. I looked at cascade, but dont think its what I need.

so im trying to setup rules so that any url matching /post/[year]/[month]/[day] format would be picked up by post.md. Not too worried about the content in post.md rendering this will just output placeholder HTML for the moment.

Thanks in advance

you can define an page url in frontmatter - this overwrites (IMHO) the permalink definition

want to config the path for all posts ? set permalinks

more to aliases here

Don’t know if you can use “:” items here (:year etc) - but you can look if what hugo creates

you can customize the alias files


Thanks for getting back @ju52 , but not sure that will handle any url with said pattern? AFAIK with alias’s you need to, for want of a better term, hardcode the path, but I dont know the path in advance I just know it will be of a certain pattern.

for all posts you can set this in your config file, I use this (toml format)

    post   = "/:section/:year/:month/:day/:title"

Was trying this - but does rely on you actually having a physical file at the end of the url? I am trying to map the above structure to just one file >> post.md under my blog folder

YES, this will store all generated files for the post section under this path.

For a single file you must set the alias in frontmatter.
IF :year/:month … does not work, open an issue as suggestion in github.

Think there is a mis-communication here. I want the url pattern to work POST build with hugo files deployed to web server.


Wildcard aliases are not supported. You need to handle this with redirects/rewrites on your server/host.

1 Like