CLI scaffolding for creating Docusaurus docs, pages, and categories
A
Anand
Creating a new page in Docusaurus is simple, but there is still some repetitive manual work involved when starting new content. Developers need to create the appropriate file or directory and decide which front matter and metadata should be included.
Docusaurus supports front matter such as
_category_.json
, title
, description
, id
, and slug
, which can be useful for SEO and page organization.It would be useful if Docusaurus provided an official, Docusaurus-aware way to scaffold new content from the CLI.
## Proposed feature
Add a CLI command for creating and scaffolding different types of Docusaurus content.
For example:
```bash
npx docusaurus create doc getting-started
```bash
npx docusaurus create page about
```bash
npx docusaurus create category tutorials
When the command is executed, it could interactively prompt the user for important information depending on the content type, such as:
* Title
* Description
* ID
* Slug
* Tags/keywords
* Category
* Author or other relevant metadata
The CLI could then generate the appropriate file/directory structure and front matter automatically.
For example:
```text
? Title: Getting Started with Docusaurus
? Description: Learn how to get started with Docusaurus
? Keywords/tags: docusaurus, documentation, tutorial
? ID: getting-started
? Slug: /getting-started
And generate something along the lines of:
```md
---
id: getting-started
title: Getting Started with Docusaurus
description: Learn how to get started with Docusaurus
slug: /getting-started
keywords:
- docusaurus
- documentation
- tutorial
---
Getting Started with Docusaurus
```
The exact metadata and generated structure could depend on the type of content being created.
## Why this could be useful
* Reduces repetitive setup when creating new content
* Makes the expected Docusaurus structure easier to discover
* Helps users avoid forgetting useful metadata
* Encourages consistent metadata across a documentation site
* Makes it easier for users to provide SEO-relevant information when creating pages
* Provides a better developer experience for users who frequently create documentation
There was a similar feature request in 2020 for a CLI command to generate Markdown files. However, that proposal focused primarily on generating a Markdown file and updating
sidebars.js
. This proposal is intended as a broader content scaffolding experience
for different Docusaurus content types, with interactive metadata collection.I’m interested in building this feature myself if there is interest from the community and the maintainers.