[SOLVED] How to setup permalinks for all pages?

#1

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.

#2

Show us what your config.toml looks like.

Also, give this a read:

#3

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?

#4

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/

#5

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.

#6

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

#7

see here

#8

You are missing a [SPACE]

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

2 Likes
#9

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

#10

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

#11

Yes. From https://gohugo.io/content-management/urls/ :

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
#12

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 https://gohugo.io/content-management/urls/#permalinks-configuration-example). 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:

#13

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.

#14

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: