mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 08:07:26 +02:00
8 lines
No EOL
13 KiB
HTML
8 lines
No EOL
13 KiB
HTML
<html><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/><title>CLI Commands · Docusaurus</title><meta name="viewport" content="width=device-width"/><meta property="og:title" content="CLI Commands · Docusaurus"/><meta property="og:type" content="website"/><meta property="og:url" content="https://docusaurus.io/index.html"/><meta property="og:description" content="Docusaurus provides a set of scripts to help you generate, serve, and deploy your website. These scripts can be invoked with the `run` command when using Yarn or npm. Some common commands are:"/><meta name="robots" content="noindex"/><link rel="shortcut icon" href="/img/favicon.png"/><link rel="stylesheet" href="/css/main.css"/><script async="" defer="" src="https://buttons.github.io/buttons.js"></script></head><body class="sideNavVisible"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img src="/img/docusaurus.svg"/><h2>Docusaurus</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li><a href="/docs/installation.html" target="_self">Docs</a></li><li><a href="/en/help.html" target="_self">Help</a></li><li><a href="https://github.com/facebookexperimental/docusaurus" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><i></i></div><h2><i>›</i><span>API</span></h2></div><div class="navGroups"><div class="navGroup navGroupActive"><h3>Getting Started</h3><ul><li class="navListItem"><a class="navItem" href="/docs/installation.html#content">Installation</a></li><li class="navListItem"><a class="navItem" href="/docs/site-preparation.html#content">Site Preparation</a></li><li class="navListItem"><a class="navItem" href="/docs/site-creation.html#content">Creating your site</a></li></ul></div><div class="navGroup navGroupActive"><h3>Guides</h3><ul><li class="navListItem"><a class="navItem" href="/docs/custom-pages.html#content">Custom Pages</a></li><li class="navListItem"><a class="navItem" href="/docs/navigation.html#content">Navigation and Sidebars</a></li><li class="navListItem"><a class="navItem" href="/docs/blog.html#content">Adding a Blog</a></li><li class="navListItem"><a class="navItem" href="/docs/translation.html#content">Translations</a></li><li class="navListItem"><a class="navItem" href="/docs/search.html#content">Enabling Search</a></li><li class="navListItem"><a class="navItem" href="/docs/versioning.html#content">Versioning</a></li></ul></div><div class="navGroup navGroupActive"><h3>API</h3><ul><li class="navListItem navListItemActive"><a class="navItem navItemActive" href="/docs/commands.html#content">CLI Commands</a></li><li class="navListItem"><a class="navItem" href="/docs/api-pages.html#content">Pages and Styles</a></li><li class="navListItem"><a class="navItem" href="/docs/site-config.html#content">siteConfig.js</a></li><li class="navListItem"><a class="navItem" href="/docs/doc-markdown.html#content">Markdown Features</a></li></ul></div></div></section></div><script>
|
||
var toggler = document.getElementById('navToggler');
|
||
var nav = document.getElementById('docsNav');
|
||
toggler.onclick = function() {
|
||
nav.classList.toggle('docsSliderActive');
|
||
};
|
||
</script></nav></div><div class="container mainContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/facebookexperimental/docusaurus/edit/master/docs/api-commands.md" target="_blank">Edit this Doc</a><h1>CLI Commands</h1></header><article><div><p>Docusaurus provides a set of scripts to help you generate, serve, and deploy your website. These scripts can be invoked with the <code>run</code> command when using Yarn or npm. Some common commands are:</p><ul><li><a href="/docs/commands.html#docusaurus-start-port-number" target=""><code>yarn run start</code></a>: build and serve the website from a local server</li><li><a href="/docs/commands.html#docusaurus-examples" target=""><code>yarn run examples</code></a>: create example configuration files</li></ul><h2><a class="anchor" name="running-from-the-command-line"></a>Running from the command line <a class="hash-link" href="#running-from-the-command-line">#</a></h2><p>The scripts can be run using either Yarn or npm. If you've already gone through our Getting Started guide, you may already be familiar with the <code>start</code> command. It's the command that tells Docusaurus to run the <code>docusaurus-start</code> script which generates the site and starts up a server, and it's usually invoked like so:</p><pre class="prism language-javascript">yarn run start</pre><p>The same script can be invoked using npm:</p><pre class="prism language-javascript">npm run start</pre><p>To run a particular script, just replace the <code>start</code> command in the examples above with the command associated with your script.</p><h2><a class="anchor" name="using-arguments"></a>Using arguments <a class="hash-link" href="#using-arguments">#</a></h2><p>Some commands support optional arguments. For example, to start a server on port 8080, you can specify the <code>--port</code> argument when running <code>start</code>:</p><pre class="prism language-javascript">yarn run start <span class="token operator">--</span>port <span class="token number">8080</span></pre><p>If you run Docusaurus using npm, you can still use the command line arguments by inserting a <code>--</code> between <code>npm run <command></code> and the command arguments:</p><pre class="prism language-javascript">npm run start <span class="token operator">--</span> <span class="token operator">--</span>port <span class="token number">8080</span></pre><h2><a class="anchor" name="configuration"></a>Configuration <a class="hash-link" href="#configuration">#</a></h2><p>These scripts are set up under the <code>"scripts"</code> key in your <code>website/package.json</code> file as part of the installation process. If you need help setting them up again, please refer to the <a href="/docs/installation.html" target="">Installation guide</a>.</p><p>Docusaurus provides some default mappings to allow you to run commands following Node conventions. Instead of typing <code>docusaurus-start</code> every time, you can type <code>yarn run start</code> or <code>npm start</code> to achieve the same.</p><h2><a class="anchor" name="commands"></a>Commands <a class="hash-link" href="#commands">#</a></h2><ul><li><a href="#docusaurus-build" target=""><code>docusaurus-build</code></a></li><li><a href="#docusaurus-examples-feature" target=""><code>docusaurus-examples [feature]</code></a></li><li><a href="#docusaurus-publish" target=""><code>docusaurus-publish</code></a></li><li><a href="#docusaurus-rename-version-currentversion-newversion" target=""><code>docusaurus-rename-version <currentVersion> <newVersion></code></a></li><li><a href="#docusaurus-start-port-number" target=""><code>docusaurus-start [--port <number>]</code></a></li><li><a href="#docusaurus-version-version" target=""><code>docusaurus-version <version></code></a></li><li><a href="#docusaurus-write-translations" target=""><code>docusaurus-write-translations</code></a></li></ul><hr/><h2><a class="anchor" name="reference"></a>Reference <a class="hash-link" href="#reference">#</a></h2><h3><a class="anchor" name="docusaurus-build"></a><code>docusaurus-build</code> <a class="hash-link" href="#docusaurus-build">#</a></h3><p>Alias: <code>build</code>.</p><p>Generates the static website, applying translations if necessary. Useful for building the website prior to deployment. </p><p>See also <a href="/docs/commands.html#docusaurus-start-port-number" target=""><code>docusaurus-start</code></a>.</p><hr/><h3><a class="anchor" name="docusaurus-examples-feature"></a><code>docusaurus-examples [feature]</code> <a class="hash-link" href="#docusaurus-examples-feature">#</a></h3><p>Alias: <code>examples</code></p><p>When no feature is specified, sets up a minimally configured example website in your project. This command is covered in depth in the <a href="/docs/site-preparation.html" target="">Site Preparation guide</a>. Specify a feature <code>translations</code> or <code>versions</code> to generate the extra example files for that feature.</p><hr/><h3><a class="anchor" name="docusaurus-publish"></a><code>docusaurus-publish</code> <a class="hash-link" href="#docusaurus-publish">#</a></h3><p>Alias: <code>publish-gh-pages</code></p><p><a href="/docs/commands.html#docusaurus-build" target="">Builds</a>, then deploys the static website to GitHub Pages. This command is meant to be run during the deployment step in Circle CI, and therefore expects a few environment variables to be defined:</p><ul><li><code>GIT_USER</code>: The git user to be associated with the deploy commit.</li><li><code>CIRCLE_BRANCH</code>: The git branch associated with the commit that triggered the CI run.</li><li><code>CIRCLE_PROJECT_USERNAME</code>: The GitHub username or organization name that hosts the git repo, e.g. "FacebookExperimental".</li><li><code>CIRCLE_PROJECT_REPONAME</code>: The name of the git repo, e.g. "Docusaurus".</li><li><code>CI_PULL_REQUEST</code>: Expected to be truthy if the current CI run was triggered by a commit in a pull request.</li></ul><p>You can learn more about configuring automatic deployments with CircleCI in the <a href="publishing.md" target="_blank">Publishing guide</a>.</p><hr/><h3><a class="anchor" name="docusaurus-rename-version-currentversion-newversion"></a><code>docusaurus-rename-version <currentVersion> <newVersion></code> <a class="hash-link" href="#docusaurus-rename-version-currentversion-newversion">#</a></h3><p>Alias: <code>rename-version</code></p><p>Renames an existing version of the docs to a new version name.</p><p>See the <a href="/docs/versioning.html#renaming-existing-versions" target="">Versioning guide</a> to learn more.</p><hr/><h3><a class="anchor" name="docusaurus-start-port-number"></a><code>docusaurus-start [--port <number>]</code> <a class="hash-link" href="#docusaurus-start-port-number">#</a></h3><p>Alias: <code>start</code>. </p><p>This script will build the static website, apply translations if necessary, and then start a local server. The website will be served from port 3000 by default.</p><hr/><h3><a class="anchor" name="docusaurus-version-version"></a><code>docusaurus-version <version></code> <a class="hash-link" href="#docusaurus-version-version">#</a></h3><p>Alias: <code>version</code></p><p>Generates a new version of the docs. This will result in a new copy of your site being generated and stored in its own versioned folder. Useful for capturing snapshots of API docs that map to specific versions of your software. Accepts any string as a version number.</p><p>See the <a href="/docs/versioning.html" target="">Versioning guide</a> to learn more.</p><hr/><h3><a class="anchor" name="docusaurus-write-translations"></a><code>docusaurus-write-translations</code> <a class="hash-link" href="#docusaurus-write-translations">#</a></h3><p>Alias: <code>write-translations</code></p><p>Writes the English for any strings that need to be translated into an <code>website/i18n/en.json</code> file. The script will go through every file in <code>website/pages/en</code> and through the <code>siteConfig.js</code> file and other config files to fetch English strings that will then be translated on Crowdin. See the <a href="/docs/translation.html" target="">Translation guide</a> to learn more.</p></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="versioning.html#content">← Previous</a><a class="docs-next button" href="api-pages.html#content">Next →</a></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/docusaurus_monochrome.svg" alt="Docusaurus" width="66" height="58"/></a><div><h5>Docs</h5><a href="
|
||
/docs/installation.html">Getting Started</a></div><div><h5>Community</h5><a href="/en/users.html">User Showcase</a></div><div><h5>More</h5><a href="https://github.com/facebookexperimental/docusaurus">GitHub</a><a class="github-button" href="https://github.com/facebookexperimental/docusaurus" data-icon="octicon-star" data-count-href="/facebookexperimental/docusaurus/stargazers" data-count-api="/repos/facebookexperimental/docusaurus#stargazers_count" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><a href="https://code.facebook.com/projects/" target="_blank" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright © 2017 Facebook Inc.</section></footer></div></body></html> |