Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

Creating Scaffolds

Getting started

First, its highly recommended that you read the official documentation before you embark on creating your scaffold.

A useful tip is to start off by creating your new scaffold in the ~/.grunt-init directory.

This is particularly handy as grunt will already see it as a scaffold that can be run. This makes it easier to test as you can run $ grunt-init [scaffold-name] in an empty folder to see how it works.

File Structure

This scaffold will give you the following file structure:

  • template.js - The main template file.
  • /root - All files to be copied are located here.
  • - Basic instructions on installing and using your scaffold.


You can prompt users to input specific input that can then be used later to when processing your scaffold. These prompts can provide information to replace placeholders within template files.

Built in prompts

Grunt provides you with a number of default prompts that generate smart defaults. Some examples are:

  • name - defaults to the current working directory name.
  • title - defaults to the project name, but made more human readable.
  • author_name - defaults to the git config user name
  • author_email - defaults to the git config user email
Using prompts in templates

Use {%= property %} to use prompt properties within files. As an example, to use the title of the project in an index.html file:

        <title>{%= title %}</title>
        <p>An awesome project!</p>


You can scaffold package.json, or any .json file using init.writePackageJSON(filename, props);. This is particularly useful when the contents of the package file is dependent on the user prompts.