Posted: July 1, 2023 | Categories: Eleventy
When I created the Eleventy Generate Posts command-line utility, I configured the command to expect all of its configuration parameters on the command-line. I did this thinking it would be simple to use, but weeks later I already forgot which command-line options I needed in what order.
I migrated a couple of Wordpress sites to Eleventy using the wordpress-export-to-markdown and that utility does an excellent job prompting for all of its configuration options. With that in mind, I decided to do the same thing with my
With this version, just published, you can execute the utility using:
npm will pull down the utility and execute, prompting you for the information it needs to execute as shown below:
│ 11ty Generate Posts │
by John M. Wargo (https://johnwargo.com)
√ Target folder for generated posts? ... posts
√ Number of posts to generate? ... 10
√ Post tag? ... post
√ Start year for generated posts? ... 2023
√ Use year folder for posts? ... yes
Number of posts: 10
Target Folder: posts
Start Year: 2023
Year mode: enabled
Output folder: D:\dev\node\11ty-generate-posts\posts
Configuration options are:
- Posts Folder: Relative path pointing to the Eleventy project's posts folder; use
.for the current folder.
- Number of Posts: An integer value between 1 and 100 representing the number of posts generated.
- Post Tag: The front matter
tagproperty applied to the generated posts
- Start Year: The starting year used for post date in the generated posts. The command uses the current date or the current date with the specified year (when provided) to for the post date for the first generated post. For subsequent post dates, the command randomly decrements the day.
- Year Mode: Specifies whether the module writes generated posts to the Posts folder (
N) or into a separate folder for each year (
Obviously if you generate enough posts to push into the previous year, the posts will save into a folder for the previous year.
To enable debug mode, pass a
-d flag on the command-line; in this mode, the module writes additional information to the console as it executes.
Next Post: Coding One-Handed
Previous Post: All Things Open 2023 Speakers
If this content helps you in some way, please consider buying me a coffee.
Header image: Eleventy Project Home Page.