This pipeline converts Hugo content pages to page leaf bundles.
From:
`-- content
|-- about.md
`-- post
|-- content-1.md
|-- content-2.md
|-- content-3.md
`-- static
`|-- images
|-- image-1.jpg
|-- image-2.jpg
|-- image-3.jpg
To:
`-- content
|-- about.md
`-- post
`-- content-1
|-- index.md
`-- images
|-- image-1.jpg
`-- content-2
|-- index.md
`-- images
|-- image-1.jpg
|-- image-2.jpg
to run me, you need pypyr.
this assumes Python 3.6 or higher.
tl;dr:
$ pip install pypyr
Run from the root of your Hugo site repo.
Put the attached flat-to-bundle.yaml
file into a directory ./ops
.
This is just for tidiness, you can put the flat-to-bundle.yaml
file in root, in which case you run it $ pypyr flat-to-bundle
, or in any other dir, in which case you run $ pypyr my-dir/flat-to-bundle
# use a glob to specify a bunch of files to process in one go:
$ pypyr ops/flat-to-bundle in='content/posts/post*.md'
# process a single file:
$ pypyr ops/flat-to-bundle in='content/posts/post1.md'
# set parent out directory (default is content/posts/out):
$ pypyr ops/flat-to-bundle in='content/posts/post*.md' out=content/out
# set image destination sub-directory in the bundle:
$ pypyr ops/flat-to-bundle in='content/posts/post*.md' out=content/out out_img=img
# set image source root directory (default is './static'):
$ pypyr ops/flat-to-bundle in='content/posts/post*.md' out=content/out in_img=assets out_img=img
You don't have to specify all of these, unless you want something other than the default values.
in
: look for a file or bunch of files depending on this input glob. Defaultcontent/posts/*.md
out
: create the bundles in this output directory. Defaultcontent/posts/out
in_img
: root directory for input images. Defaultstatic
. If you keep your images inassets
, change that here.out_img
: sub-directory for images in the output bundle. Defaultimages
.
Tested with the following styles of markdown image declarations:



Note: NOT particularly tested with image-within-link.
Note: unlikely to work as-is with multi-lingual - you might need to tweak line 61 & 63 for this.