Creating page bundles in one click

Hi,

I have hosted my site in Git Hub via Hugo. Hugo recommends “page bundles” approch.
That is, for each note, I have to create a directory by that name, then create an index.md inside it.
eg:
:open_file_folder: my_first_blog/:spiral_notepad:index.md
:open_file_folder: my_second_blog/:spiral_notepad:index.md

I have dataview, templater, and periodic daily notes plugin.

I should be able to “click on a button in the ribbon” OR “select a command”. First, it should ask for a prompt for giving the note title, then it should create a new directory (by that title), then create an "index.md" file inside it.

Is this functionality possible using dataview and templater ? Can it create a directory and file inside it in one click ? Please share your idea.

It will be possible with templater. I’ve never done it so I couldn’t help you, but with this doc you’ll find out how to create a file and retrieve a value from a promp. To create a folder, there must be a way, but I don’t have the exact solution.

1 Like

Set this as periodic note daily note template. click the button and it will prompt. Working.

<%*
let qcFileName = await tp.system.prompt("Note Title")
let titleName = qcFileName
await tp.file.rename('index')
let baseFolder = "/content/post/"
let newFolder = `${baseFolder}/${titleName}/` 
await tp.file.move(newFolder + `index`);
let title = titleName
let description = ""
let slug = ""
let date = ""
let image = ""
let categories = ""
let tags = ""
let weight = ""
setTimeout(() => { app.fileManager.processFrontMatter(tp.config.target_file, frontmatter =>{ frontmatter["title"] = title; 
frontmatter["description"] = description; 
frontmatter["slug"] = slug; 
frontmatter["date"] = date; 
frontmatter["image"] = image; 
frontmatter["categories"] = categories; 
frontmatter["tags"] = tags; 
frontmatter["weight"] = 1; 
}) }, 200)
-%>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.