Compare Cookiecutter to Yeoman

What are the similarities and differences between the two big scaffolding tools, and what’s right for your project?

Share this article

Using project templates for new code is the best way to save time and energy for engineering teams, not to mention to build consistency and standardization in these new projects. Project templates — also known as scaffolding, project bootstrap tools, boilerplate generation and skeletons — help avoid repetitive and tedious tasks while removing unnecessary information in the new code. 

Providing such a crucial function for teams is no easy task, and many tools exist to fill this role. The two best-known ones are Cookiecutter and Yeoman — although alternatives exist, including Copier, Cortex Scaffolding, Plop, and more. So what makes these two the big players, and what are the similarities and differences and pros and cons of each? Plus, which is better for your project?

Cookiecutter: A deep dive into the well-known industry standard

Known as the industry standard of scaffolding tools, Cookiecutter is an open-source command-line utility that allows developers to use customizable templates and generate services from them. Engineers can create their own templates for projects, or search Cookiecutter’s well-stocked GitHub library for pre-made templates for new projects.

Some details about Cookiecutter: As a command-line utility tool, you can download the package and run it on the command line of your computer. You’ll install it using pip or conda. It works cross-platform, so it can run on Windows, Mac, and Linux.

Even though the tool was coded and built in Python, it’s language agnostic, though templates rely on Python-based Jinja2’s syntax. Project templates can generate boilerplate code, or “cookiecutters,” in any programming language or markup format, from Python to JavaScript to Ruby to CoffeeScript to RST to Markdown to CSS to HTML, and you can even use multiple languages in the same project template. The boilerplate generated could be, for example, Python package projects, C projects,  jQuery plugin projects, web applications, or even machine learning apps with complex workflows.

Here’s how it works: Once you’ve installed the command-line interface (CLI) tool, you will start your project with a cookiecutter.json file. This opens up a {{ cookiecutter.project_name }}/ directory. Your template variables are defined in the cookiecutter.json file, including the project_name. After, you add desired files/directories. 

Cookiecutter has a few questions to personalize the template — users specify how to name your project, what the license is, directory names and filenames, and certain project dependencies, among other script decisions, then it generates the skeleton. You can also set it to generate an automatic README file or Changelog as checks, and you can choose if you want the generated template to exist in PyPI.

Essentially, Cookiecutter is cloning a directory and putting it inside your new project. It then replaces all the names that are between {{ and }} (that’s the Jinja2 syntax) with names that it finds in the cookiecutter.json file.

Cookiecutter also supports unlimited levels of directory nesting. Plus, it can be used with templates that live in a Git repo, a folder or even a Zip file. It also has plugins such as a pytest plugin, which comes with integrations for the cookiecutter API. It also can integrate with Lint to check your code, or with Microsoft Visual Studio and other tools you might already use.

Some benefits of Cookiecutter: It already has an established, active community, so many of your questions might have already been answered (and you can go read the docs to find out). In addition, many templates you might be looking for likely already exist as examples (You can search for specific and ready-to-use cookiecutter templates in Github search — if you type cookiecutter to find over 4000 related repositories). The tool has a particular focus on being config first, because it’s stable and configuration-driven, which makes the projects relatively easier to debug than other options. 

Yeoman: Exploring the usability and benefits of the newcomer tool

Yeoman is another popular scaffolding open-source command-line interface (CLI) tool, similar to Cookiecutter. Originally developed for web applications, it creates project templates for those kinds of projects and can significantly help streamline the development process for them. It was originally used to automate frontend efforts such as creating navigation, headers and footers for apps, but now is also commonly used for backend tasks such as creating APIs, creating new sections of a project (like a new controller with unit tests), or creating modules or packages.

Some more details about Yeoman: Like Cookiecutter, Yeoman is also a command-line utility, installed using npm, the built-in Node.js-based HTTP development server. It too works cross-platform, though it is based on JavaScript. However, it can create applications in any programming language, including Web, Java, Python, C#, etc.  

Here’s how it works: Yeoman is more of an ecosystem than a tool on its own — you will download the Yeoman generator package, which has many plugins that are generators to help make decisions. Yeoman’s main offering is a scaffolding tool (called ‘yo’), which generates the templates for a new application. You start your project with a package.json file in yo. Yo is also fully interactive, and can manage everything related to additional generators: run, update, install, help and other utilities.

After installing yo, users can install needed generator(s), which are npm packages named generator-XYZ. There are several generators on Yeoman’s website, or you can make your own, and you can install them from Yeoman’s digital library or from the menu while running yo. (If there are permissions issues, you can find solutions in the npm guide to fix permissions).

Then, you’ll use other generators to scaffold the parts of a project (generators scaffolding complex frameworks will even provide additional generators for the smaller parts, known as subgenerators). A lot of generators rely on build systems (like Gulp or Grunt, which has more modules built for it than Gulp, but is more complex and requires more configuration). They also utilize package managers (like npm and Bower, which manages library dependencies). 

Most generators will ask a series of questions to customize the new project. Users can see which options are available using the help command (yo webapp --help). Developers can even create their own generators, with a tool called generator-generator.

Benefits include: Yeoman offers more flexible automation, such as the ability to programmatically generate files in the template and even write unit tests on the generated files. The user experience is also superior to Cookiecutter, as the tool is more modern. 

Similarities
& Differences

Programmed in

Python

Java

Output template language

Any desired

Any desired

Operating system

Windows, MacOS, and Linux

Windows, MacOS, and Linux

Configuration functions

Default configuration in a JSON file (can cause trouble with dynamic configurations)

Default configuration in JS module

Generators

No composable generators

Many generator options, including composable generators

Adding code to existing projects

Hard - you need a new folder with the new things you want added and it will recreate a new project template

Medium - you can pass a process function as an option to do any modifications to the content

Template package format

Git or mercurial repo, Zip file

NPM package

Templating engine

Jinja

EJS

Price

Free, open-source

Free, open-source

Similarities and differences between Cookiecutter and Yeoman

Programmed in

Python

Output template language

Any desired

Operating system

Windows, MacOS, and Linux

Configuration functions

Default configuration in a JSON file (can cause trouble with dynamic configurations)

Generators

No composable generators

Adding code to existing projects

Hard - you need a new folder with the new things you want added and it will recreate a new project template

Template package format

Git or mercurial repo, Zip file

Templating engine

Jinja

Price

Free, open-source

Programmed in

Java

Output template language

Any desired

Operating system

Windows, MacOS, and Linux

Configuration functions

Default configuration in JS module

Generators

Many generator options, including composable generators

Adding code to existing projects

Medium - you can pass a process function as an option to do any modifications to the content

Template package format

NPM package

Templating engine

EJS

Price

Free, open-source

What’s best for your project?

Using productivity tools such as project templating software is helpful, but there’s no one-size-fits-all approach. Projects, teams, and companies are all unique, and so figuring out the right tool is also a unique opportunity. 

While Yeoman likely has more template options for web applications and more generators for specific adds, Cookiecutter still holds up as a tried-and-true project templating tool with an active community. While the Yeoman ecosystem is more powerful, sometimes, the simplicity of Cookiecutter is easier to work with and all you need. In short, it depends on your project and your preferences as a developer.

Ready to use Cookiecutter?