Matching Wordpress Urls for Hugo blog site

I’m currently migrating from a Wordpress site over to Hugo and I’m struggling to match the Urls.

For example wordpress follows the format of:


Is there a way I can define a category in the front matter in order to have different directories for different posts?

Perhaps in config.toml

categoryname = "/categoryname/:slug" check here for more information.

Is there a way I can define a category in the front matter in order to have different directories for different posts?

If I understand correctly, you don’t need to muck about in the front matter. Use the Permalinks to turn your URL into whatever you want.

Thanks for the response Hash, however I’m not sure how this would work.

Where would the jquery and front-end-dev variables come from with your example?


I am unsure what this has to do w/ matching URLs from WP to Hugo. I would require more information about exactly what you’re trying to do.

My hugo URL’s have a slug property, but I cannot see how I can set a category, they are all prepended by post instead of a custom category.

From my previous post I used the following two as an example:

This is now in the format of:

Where I have post I wish to switch this to jquery for this particular article.

Is there something I am missing?


Use Aliases on the frontmatter of each post.

Thanks, the alias is a great way of ensuring my old links still point to the same content, however I would prefer to use the original URLs moving forward as these will be better for SEO.

Is this at all possible?

I see. Well then inside your content folder create a folder named jquery and move said post in it.

The post should now be available at your desired url

The simplest way to organize posts by Category in Hugo is by grouping them in separate folders.

For example posts with the /post/ slug will go under /content/post
Posts with the slug /jquery/ go into /content/post and so on.

Also make sure that your config toml file does not contain a categoryname parameter with a URL structure under /post/ if it does delete it. Don’t know why some theme authors like to interfere with the URL structure in the config.

This works perfectly - thanks!

The post is no longer appearing in my article list, but I suspect this is a restriction with the theme I’m using…

Well then go to your /layouts/_default folder open list.html and your /layouts/index.html file

Your articles list is rendered in category pages and in the index with something along the lines of

{{ range .Data.Pages }}
<div class="post-item">
<a href="{{ .Permalink }}" class="post-link">
{{ .Title }}
{{ end }}

Could you look into these 2 files and post the relevant part of the template here, so that I can see how it’s structured?

It might limit the rendering of your articles under /post/ only.

Thanks I’ve taken a look and theres a where clause ensuring the posts have a “Type” of “Post” only.

Is there a way of setting the Type in the front matter?

You shouldn’t bother with changing the frontmatter in each post.

You probably have {{ range where .Data.Pages "Type" "post" }} in your template simply replace it with {{ range .Data.Pages }} in both files (list.html and index.html) and you should be fine.

Check first with hugo server if everything renders normally. If not revert above change and look for more info in the Docs about ordering and displaying content or contact the theme designer for help.