# HUGO postmaker (batch script) for Windows 10

**URL:** <https://discourse.gohugo.io/t/hugo-postmaker-batch-script-for-windows-10/26242>\
**Category:** tips & tricks\
**Created:** [June 13, 2020, 10:09pm UTC](https://discourse.gohugo.io/t/hugo-postmaker-batch-script-for-windows-10/26242 "2020-06-13T22:09:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![s1-en](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@s1-en](https://discourse.gohugo.io/u/s1-en)\
**Post date:** [June 13, 2020, 10:09pm UTC](https://discourse.gohugo.io/t/hugo-postmaker-batch-script-for-windows-10/26242/1 "2020-06-13T22:09:27Z")

</div>

Hello, I was working on a small helper utility to automate folder hierarchy and and page bundle generation for hugo. I made it for my own personal use but I figured others might benefit from it too.

It’s written in Batch script and yes, I had to tear my hair out the whole time I was writing it.

**Prerequisites:**  
Before anything else, place the `pm.bat` in your hugo project main folder. You can rename it to whatever you want, it will still work the same. The reason it needs to reside in the project’s folder is because it uses relative paths to do things. Also the `hugo` CLI must be accessible from your project’s folder too (obviously).

![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/4/4c86ef6772d9eb44ee98801446b9960a78eb878b.png)

**What can it do?**  
Here’s what shows up when you do `pm help` or `pm /?` or `pm -h`

> **Show Snippet**
>
> ```
> C:\hugotest>pm help
> HUGO postmaker 1.1 (by s1)
> 
> For more info, visit:
> https://discourse.gohugo.io/t/26242/
> 
> HUGO postmaker helps easily create posts structured inside folders.
> 
> NOTICE: This needs to be placed in your HUGO project's main folder.
> 
> USAGE: pm [-b, bundle] <command> <post-filename> [<extra languages>]
> (Don't add *.md at the end of filename.)
> 
> COMMANDS:
> 
> b, -b, (Optional) Use to specify that you want a page bundle created
> bundle, instead of a single Markdown file.
> --bundle
> 
> post Creates a new post if it doesn't exist already.
> page Creates a new page if it doesn't exist already.
> section Creates a new section if it doesn't exist already.
> help Opens this help section.
> version Show version information.
> 
> EXTRA LANGUAGES:
> 
> Applies only to post, page and bundle mode section commands.
> 
> You can add any space-delimited language codes and postmaker will create a
> copy of the created Markdown file while adding the language code to its
> filename. (See usage examples below.)
> 
> ADDITIONAL CONFIG:
> 
> Applies only to post command.
> 
> To change these additional configs, Open up "pm.bat"
> in a text editor and change the values in the top part of the script.
> It should be self explanatory.
> 
> post_section, post_format
> You can set the hierarchy of your post's folder structure. By default, the
> format used is "yyyy/MM/dd" and the section is set to "posts".
> 
> NOTICE: post_format only accepts date format as of right now.
> 
> EXAMPLES:
> 
> pm post hello-world
> 
> The above command creates:
> - posts/2020/06/14/hello-world.md
> 
> pm post hello-world ja es de
> 
> The above command creates:
> - posts/2020/06/14/hello-world.md
> - posts/2020/06/14/hello-world.ja.md
> - posts/2020/06/14/hello-world.es.md
> - posts/2020/06/14/hello-world.de.md
> 
> pm post -b hello-world ja es de
> 
> The above command creates:
> - posts/2020/06/14/hello-world/index.md
> - posts/2020/06/14/hello-world/index.ja.md
> - posts/2020/06/14/hello-world/index.es.md
> - posts/2020/06/14/hello-world/index.de.md
> 
> pm page stuff/my-page
> 
> The above command creates:
> - stuff/my-page.md
> 
> pm page stuff/my-page ja
> 
> The above command creates:
> - stuff/my-page.md
> - stuff/my-page.ja.md
> 
> pm section random
> 
> The above command creates:
> - random/
> 
> pm -b section random
> 
> The above command creates:
> - random/_index.md
> 
> pm -b section random ja es
> 
> The above command creates:
> - random/_index.md
> - random/_index.es.md
> 
> ```

**Some screenshots**

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/7/708af2a10cb738b206b979159147690c6df45269.png) ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/f/f95acbaa2a6578812865e356f99833368fe3cf64.png) ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/e/e100287fdddb046f2c2f65e1bf39fbc1aa461f29.png)

**Where to get it?**  
I put it on Github

> <https://gist.github.com/s1-en/13b561d404a0bd2bd863a9b66ce31c96>

  
Or you can download the zip  
[https://mega.nz/file/UstH3JoS#zJy8qC7lsf99RnMhyhsmtIvhoX--Bumj7P7aF\_iikUY](https://mega.nz/file/UstH3JoS#zJy8qC7lsf99RnMhyhsmtIvhoX--Bumj7P7aF_iikUY)

**Typical disclaimer**  
I just provide this script as is. It is your responsibility to test it out first on a dummy project before using it in your actual project. I’ve been using it but I’m just one person so you might stumble across edge cases that I didn’t think about beforehand.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [June 14, 2020, 2:19pm UTC](https://discourse.gohugo.io/t/hugo-postmaker-batch-script-for-windows-10/26242/2 "2020-06-14T14:19:23Z")

</div>

Have you seen archetype directories?

> **[Archetypes](https://gohugo.io/content-management/archetypes/#directory-based-archetypes)**
>
> Archetypes are templates used when creating new content.

That might change your bundle approach. 🙂

---

<div class="post-metadata">

**Author:** ![cblte](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cblte/32/14200_2.png) [@cblte](https://discourse.gohugo.io/u/cblte)\
**Post date:** [April 26, 2021, 4:18pm UTC](https://discourse.gohugo.io/t/hugo-postmaker-batch-script-for-windows-10/26242/3 "2021-04-26T16:18:36Z")

</div>

Hi there,

This is a nice script. It did help me fix my script a little bit. And also thank you for mentioning post-bundle-directories. This is something I have never though about.
