[SOLVED] How to setup permalinks for all pages?

My md files are located in content folder,
I set permalinks: /:year/:month/:title/ in site configure.
But in the public folder doesn’t have the /year/month structure,
It’s seem permalinks doens’t work? Who can help me to solove it? Tell my what should I do.

Show us what your config.toml looks like.

Also, give this a read:

I have readed URL Management, there is example:

permalinks:
post: /:year/:month/:title/

I didn’t have post folder, so my config.ymal set is:
permalinks: /:year/:month/:title/

Is it wrong?

The configuration key needs to be for the Section under which your content files reside.

What you have would work for markdown files under a /permalinks/ directory.

Also permalinks is a table, so it needs to be:

permalinks:
some-section: /:year/:month/:title/
some-taxonomy: /whatever/:year/:month/:title/

I create a section named ‘post’, and put my markdown files under it.
then
permalinks:
post:/year/month/:tilte

but it still doesn’t works.

There can be various things at play here and it is impossible to help you further without seeing your Hugo project. If you cannot share it then create a repo with some dummy content.

Also see Requesting Help

see here

You are missing a [SPACE]

Change line 7 of your config.yaml to:
post: /:year/:month/:title/

2 Likes

Thank you very much. :grinning::grinning:
I am trouble in it for two days.

Does it must under a sections?
if i do not want use section, how? could it?

Yes. From URL management | Hugo :

The permalinks option in your site configuration allows you to adjust the directory paths (i.e., the URLs) on a per-section basis.

1 Like

First explain why you don’t want to use a section. Maybe there is a workaround.

By the way, you can load the permalink in the front matter of the content files themselves (see URL management | Hugo). That probably helps, though I’d still consider just putting all the pages in a “section” at content/pages. You can choose an arbitrary content directory, as well, so you have a lot of options.

You should start by explaining your setup and why you need to not use sections. :slight_smile:

Thanks,
I just change my site from jekyll, Jekyll is too slowly, my site have more than 9000 pages, Jekyll didn’t use sections and I am not so familiar to hugo.

My suggestion is to just put all your content from Jekyll into a single section (maybe content/posts), and set the permalink as you want. Later, you can move it or add a new section as you build out your site, etc. :slight_smile:

I know this is a pretty late reply, but hopefully it’s helpful to someone else. To set the permalinks option for pages not inside any section i.e. in the “root”, use / as the key.

Example:

[permalinks]
  "/" = "/:year/:month/:filename/"

I’ve added this example to URL management | Hugo .

1 Like