Jekyll New Page Creator
This plugin provides a create-page command for Jekyll.
It allows you to generate new pages or posts based on Liquid templates.
When a Liquid variable is present in the template but not supplied by the context, the plugin interactively prompts the user for its value using Readline.
It reduces the boilerplate required to start a new document and ensures consistency across your project.
Installation
Add this line to your application’s Gemfile inside the jekyll_plugins group:
group :jekyll_plugins do
gem 'jekyll_new_page'
endThen execute bundle install to download and install the gem.
Alternatively, you can install it yourself by running gem install jekyll_new_page.
Usage
To create a new page using a template, run the command through Jekyll.
$ bundle exec jekyll create-page [options] <Template name>The plugin looks for templates in the _template directory by default.
Command Line Options
-o, --output PATH-
The path where the new document will be created. This argument is required.
-n, --name NAME-
The name of the document. This argument is required.
--path [PATH]-
A custom path to locate the template. This overrides the default
_templatedirectory. -d, --create-subdir-
Creates a subdirectory to store the new page. The resulting file is named as an
indexfile with the proper extension.
Interactive Prompts
The core feature of this plugin is its interactive behavior.
The tool parses your Liquid template before writing the final file.
If it finds Liquid tags for variables that are not yet defined, it halts and asks you to provide them.
This prompt is done using standard terminal input.
This guarantees you never forget to fill out front matter fields like tags or categories.
After the file is written, the command automatically attempts to open it using the nvim editor.
Example
Assume you have a template named post.md in your _template directory.
---
title: {{ title }}
date: {{ date }}
author: {{ author }}
---
Start writing here...You can generate a new page with the following command.
$ bundle exec jekyll create-page -o _posts -n 2023-10-01-my-new-post post.mdThe tool will parse the template.
It will notice that title, date, and author are missing from the initial context.
It will then prompt you in the terminal for each of these variables.
You can type the values interactively.
Once all variables are gathered, the plugin processes the template and creates the file in the designated output folder.
Finally, it opens the new file in nvim.
Autocompletion and History
The plugin uses Readline to read user input.
It also stores a history of your inputs in a hidden history file.
This design allows for quick auto-completion of previously typed values.
It is specially useful for recurrent fields such as authors or tags.