Docusaurus is an easy-to-use, static site generator [ssg] that simplifies the process of building a documentation website or blog. It is developed by Facebook and open source. Docusaurus helps developers, content creators, and project maintainers create beautiful, responsive websites with ease. Docusaurus takes advantage of Markdown’s ease of use to create content using a syntax that’s familiar to users of all levels of expertise. It can let you quickly deploy a stunning documentation site.
Docusaurus depends on node.js version 18.0 or higher. To check the version, run node -v on the terminal. nvm can also be used to manage several versions of nodes on the same machine.
It is always a good idea to check all dependencies checkboxes while installing Node.js.
The Docusaurus scaffold command line tool is the simplest method to start. This tool may help you construct a Docusaurus skeleton website. The command may be used anywhere in the new empty repository or within an existing repository to create a new directory containing the scaffolded files.
npx create-docusaurus@latest my-website classic
Docusaurus strongly suggests the classic template because it has all the features of Docusaurus 1 in it. The classic template includes the following: Docusaurus/Preset-Classic with included standard documentation, A blog, Custom pages, and CSS Framework (With Dark Mode Support). You can get started with the classic template in no time and you can change things later as you get more comfortable with Docusaurus.
The docusaurus template also supports the TypeScript variant. For more information, see TypeScript support. To use the TypeScript variant of the template, you can pass the --typscript flag.
npx create-docusaurus@latest my-website classic --typescript
If you use the standard template and name your site "my-website", you'll see these files created under a new folder named "mywebsite/"
Project Structure Breakdown:
You can also use a local development server to serve your website and show your changes as you modify the files.
cd my-website
npm run start
If you prefer to use yarn or pnpm then run the below commands,
cd my-website
yarn run start
or
cd my-website
pnpm run start
After running the above command, a browser window will be opened by default at http://localhost:3000
Since Docusaurus is an up-to-date static website builder, we need to convert the website into a static content directory and upload it to a web server for viewing. To create a static website:
npm run build
or
yarn build
or
pnpm run build
Content will be created in the /build directory. The content can be copied to static file hosting services such as GitHub Pages Vercel Netlify More information can be found in the documentation on deployment.
Bravo🎉 You’ve successfully launched Docusaurus and started your first documentation or blog site. This is just the start of what’s to come with Docusaurus. Prepare yourself for a robust and flexible framework that gives you the power to build and improve your online presence.