Test a Docusaurus production build locally
build folder. By default, the site will be served at http://localhost:3000/.npm run servewebsite·Indexed 30 days ago
https://mmtk.maxttc.meDocumentation for Main Toolkit, featuring guides on getting started, creating documents, managing versions, and configuring i18n using Docusaurus.
build folder. By default, the site will be served at http://localhost:3000/.npm run serve```jsx title="src/components/HelloDocusaurus.js"
function HelloDocusaurus() {
return <h1>Hello, Docusaurus!</h1>;
}export const Highlight = ({children, color}) => (
<span
style={{
backgroundColor: color,
borderRadius: '20px',
color: '#fff',
padding: '10px',
cursor: 'pointer',
}}
onClick={() => {
alert(`You clicked the color ${color} with label ${children}`)
}}>
{children}
</span>
);
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !To create a new Docusaurus site using the classic template, run the npm init command. This process automatically adds the classic template to your project and installs all necessary dependencies.
Prerequisites:
npm init docusaurus@latest my-website classicDocusaurus allows you to manage multiple versions of your documentation. Running the docs:version command copies the current docs folder into a new versioned directory (e.g., versioned_docs/version-1.0) and creates a versions.json file to track them.
After creating a version (e.g., '1.0'), the site will have two active versions:
1.0) available at /docs/./docs/next/.npm run docusaurus docs:version 1.0docs directory into the corresponding locale folder within the i18n directory. The path structure follows the plugin name and current version: i18n/{locale}/docusaurus-plugin-content-docs/current/.mkdir -p i18n/fr/docusaurus-plugin-content-docs/current/
cp docs/intro.md i18n/fr/docusaurus-plugin-content-docs/current/intro.mddocs/intro.md) will be displayed automatically without a manual refresh.cd my-website
npm run startdocs/ directory. Docusaurus automatically serves this file at a URL corresponding to its filename. For example, a file created at docs/hello.md will be available at http://localhost:3000/docs/hello.# Hello
This is my **first Docusaurus document**!Versioned documentation is managed in separate folders. To update a specific version, edit the files within that version's directory. To update the upcoming/unreleased version, edit files in the main docs folder.
Example mapping:
versioned_docs/version-1.0/hello.md $\rightarrow$ updates http://localhost:3000/docs/hellodocs/hello.md $\rightarrow$ updates http://localhost:3000/docs/next/helloAdd Markdown (.md) or React (.js) files to the src/pages directory to create standalone pages. The file system structure determines the URL path:
src/pages/index.js maps to the root URL (/)src/pages/foo.md maps to /foosrc/pages/foo/bar.js maps to /foo/barstatic directory) or relative paths (colocated with the Markdown file).# Absolute path (static/img/logo.svg)

# Relative path
build folder.npm run build