Creating blog posts in folders and subfolders?!


#1

Hello,
Is it possible to create blog posts directly in folders and subfolders?

eg. /2019/01/03/mypost.txt

I was looking for in forum’s topics, but I haven’t found anything well…
if is possible when I can found the part of code that saves it?


#2

Yes, you can create post in folders and subfolders, but I don’t quite understand what you mean by directly? You would have to create the folders and subfolders first… Do you have that many posts that you have to store them in so many subfolders? Or what do you want to achieve?


#3

thanks @texnixe,
At moment no, but I’m performing a migration script from another cms…
I would create a hierarchical organization but, as default, folders that contains posts are created with the name convention “20181202-my-post”,
I would create a folder with Year Month and Day for each post… And if I will create two posts in a day I’ll would insert it in the same Day folder…
maybe is too difficult or isn’t possible, I mean


#4

You can do this programmatically, by creating a new page for each hierarchy level. The date in front of the folder name “20181202-my-post” is just a visibility flag, it will not become part of the URL. You can also decide not to make your pages visible (i.e. not prepend a date or number).


#6

Using the create method, it should be pretty straightforward: https://getkirby.com/docs/cheatsheet/pages/create

Don’t know what sort of script you are using, but within your script, you would have to get the date “partials” from your original articles and the build the structure step by step.


#7

Thank you @texnixe
very kind :slight_smile: