<html><head><metacharset="utf-8"/><metahttp-equiv="X-UA-Compatible"content="IE=edge, chrome=1"/><title>getting-started · Docusaurus</title><metaname="viewport"content="width=device-width"/><metaproperty="og:title"content="getting-started · Docusaurus"/><metaproperty="og:type"content="website"/><metaproperty="og:url"content="https://docusaurus.io/index.html"/><metaproperty="og:description"content="## Getting Started"/><metaname="robots"content="noindex"/><linkrel="shortcut icon"href="/img/docusaurus.ico"/><linkrel="stylesheet"href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css"/><linkrel="stylesheet"href="/css/main.css"/><scriptasync=""defer=""src="https://buttons.github.io/buttons.js"></script></head><bodyclass="sideNavVisible"><divclass="fixedHeaderContainer"><divclass="headerWrapper wrapper"><header><ahref="/"><imgsrc="/img/docusaurus.svg"/><h2>Docusaurus</h2></a><divclass="navigationWrapper navigationSlider"><navclass="slidingNav"><ulclass="nav-site nav-site-internal"><li><ahref="/docs/installation.html"target="_self">Docs</a></li><li><ahref="/en/help.html"target="_self">Help</a></li><li><ahref="https://github.com/facebookexperimental/docusaurus"target="_self">GitHub</a></li><liclass="navSearchWrapper reactNavSearchWrapper"><inputtype="text"id="search_input_react"placeholder="Search"/></li></ul></nav></div></header></div></div><divclass="navPusher"><divclass="docMainWrapper wrapper"><divclass="container mainContainer"><divclass="wrapper"><divclass="post"><headerclass="postHeader"><aclass="edit-page-link button"href="https://github.com/facebookexperimental/docusaurus/edit/master/docs/getting-started.md"target="_blank">Edit this Doc</a><h1>getting-started</h1></header><article><div><h2><aclass="anchor"name="getting-started"></a>Getting Started <aclass="hash-link"href="#getting-started">#</a></h2><h3><aclass="anchor"name="project-structure"></a>Project Structure <aclass="hash-link"href="#project-structure">#</a></h3><p>In your project repo, all of your documentation files should be placed inside a <code>docs</code> folder. Any blog posts should be inside a <code>blog</code> folder. Create a <code>website</code> folder inside which you will install and run docusaurus.</p><p>Example project structure:</p><preclass="prism language-javascript">project<spanclass="token operator">-</span>repo<spanclass="token operator">/</span>
website<spanclass="token operator">/</span></pre><h3><aclass="anchor"name="installation"></a>Installation <aclass="hash-link"href="#installation">#</a></h3><p>Inside of your <code>website</code> folder, create a <code>package.json</code> file with the following scripts for Docusaurus:</p><preclass="prism language-json"><spanclass="token punctuation">{</span>
<spanclass="token punctuation">}</span></pre><p>Install Docusaurus using <code>npm</code> or <code>yarn</code>:</p><preclass="prism language-javascript">npm install <spanclass="token operator">--</span>save<spanclass="token operator">-</span>dev docusaurus</pre><p>or</p><preclass="prism language-javascript">yarn add docusaurus <spanclass="token operator">-</span>dev</pre><h2><aclass="anchor"name="configuration"></a>Configuration <aclass="hash-link"href="#configuration">#</a></h2><h3><aclass="anchor"name="generate-examples"></a>Generate Examples <aclass="hash-link"href="#generate-examples">#</a></h3><p>To create example files for configuration, run <code>examples</code> using <code>npm</code> or <code>yarn</code>:</p><preclass="prism language-javascript">npm run examples</pre><p>or</p><preclass="prism language-javascript">yarn run examples</pre><p>This will create the following files/folders in your website folder:</p><preclass="prism language-javascript">core<spanclass="token operator">/</span>Footer<spanclass="token punctuation">.</span>js
siteConfig<spanclass="token punctuation">.</span>js</pre><p>It will also create two folders in the level above the website folder in your project repo:</p><preclass="prism language-javascript">blog<spanclass="token operator">-</span>examples<spanclass="token operator">-</span><spanclass="token keyword">from</span><spanclass="token operator">-</span>docusaurus
docs<spanclass="token operator">-</span>examples<spanclass="token operator">-</span><spanclass="token keyword">from</span><spanclass="token operator">-</span>docusaurus</pre><p>If any of the files created by <code>yarn run examples</code> already exists, Docusaurus will not overwrite them.</p><p>The provided example files contain configurations for an example site. </p><p>The <code>core/Footer.js</code> file is a React component that acts as the footer for the site generated by Docusaurus and should be customized by the user.<br/>The <code>blog-examples-from-docusaurus</code> folder contains examples of blog posts written in markdown.<br/>The <code>docs-examples-from-docusaurus</code> folder contains example documentation files written in markdown.<br/>The <code>pages</code> folder contains example top-level pages for the site.<br/>The <code>static</code> folder contains static assets used by the example site.<br/>The <code>siteConfig.js</code> file is the main configuration file used by Docusaurus. </p><p>You will need to keep the <code>siteConfig.js</code> and <code>core/Footer.js</code> files, but may edit them as you wish.</p><p>You should keep the <code>pages</code> and <code>static</code> folders, but may change the content inside them as you wish. At the bare minimum you should have an <code>en/index.js</code> or <code>en/index.html</code> file inside <code>pages</code> and an image to use as your header icon inside <code>static</code>.</p><p>The <code>blog-examples-from-docusaurus</code> and <code>docs-examples-from-docusaurus</code> folders contain example blog and document markdown files. If you wish to run Docusaurus with these files, you need to rename the folders to <code>blog</code> and <code>docs</code>, respectively.</p><h3><aclass="anchor"name="how-to-configure-your-site"></a>How to Configure Your Site <aclass="hash-link"href="#how-to-configure-your-site">#</a></h3><p>Configure the <code>siteConfig.js</code> file which has comments guiding you through what needs to be done and how each configuration affects your website. You can also refer <ahref="/docs/en/site-configuration.md"target="">here</a> for more details.</p><p>Customize <code>core/Footer.js</code> which will serve as the footer for each page on your website.</p><p>Include your own top-level pages as React components in <code>pages</code>:</p><ul><li>These components should just be the body sections of the pages you want, and they will be included with the header and footer that the rest of Docusaurus uses. </li><li>Currently, if you want to add other React components to your pages, you must include all of it inside each <code>.js</code> file in <code>pages</code> due to how <code>require</code> paths are set-up. </li><li>You may also include <code>.html</code> files directly, but this is not recommended, and these will just be served as is and will not have any of the header/footer/styles shared by the rest of Docusaurus.</li><li>Any files in <code>pages/en</code> will also be copied into <code>pages</code> when the server is run and when the site is statically built. i.e. Putting a file in <code>pages/en/index.js</code> will make it available at <code>/en/index.html</code> and <code>/index.html</code>.</li></ul><p>All images and other static assets you wish to include should be placed inside the <code>static</code> folder. Any <code>.css</code> files provided in <code>static</code> will be concatenated to the standard styles provided by Docusaurus and used site-wide.</p><p>A React component placed in <code>website/pages/en/index.js</code> will be available at the url <code>/en/index.html</code>. A static html page placed in <code>website/pages/en/index.html</code> will be available at the url <code>/en/index.html</code>. Provided html files will override provided React components.</p><p>A static asset placed in <code>website/static/img/image.png</code> will be available at the url <code>/img/image.png</code>.</p><p>Example:</p><preclass="prism language-javascript">localhost<spanclass="token punctuation">:</span><spanclass="to
$<spanclass="token punctuation">{</span>url<spanclass="token punctuation">}</span>$<spanclass="token punctuation">{</span>baseUrl<spanclass="token punctuation">}</span>img<spanclass="token operator">/</span>image<spanclass="token punctuation">.</span>png</pre><h3><aclass="anchor"name="document-and-blog-front-matters"></a>Document and Blog Front Matters <aclass="hash-link"href="#document-and-blog-front-matters">#</a></h3><p>Documentation should contain front matter that follows this example:</p><preclass="prism language-javascript"><spanclass="token operator">--</span><spanclass="token operator">-</span>
id<spanclass="token punctuation">:</span> doc1 <spanclass="token operator"><</span><spanclass="token operator">!</span><spanclass="token operator">--</span> used <spanclass="token keyword">for</span> docs to find each other and to map links <spanclass="token operator">--</span><spanclass="token operator">></span>
title<spanclass="token punctuation">:</span> Document Title
layout<spanclass="token punctuation">:</span> docs1 <spanclass="token operator"><</span><spanclass="token operator">!</span><spanclass="token operator">--</span> used to determine different sidebar groupings <spanclass="token operator">--</span><spanclass="token operator">></span>
category<spanclass="token punctuation">:</span> Sidebar Category <spanclass="token number">1</span><spanclass="token operator"><</span><spanclass="token operator">!</span><spanclass="token operator">--</span> category on the sidebar under which <spanclass="token keyword">this</span> doc goes <spanclass="token operator">--</span><spanclass="token operator">></span>
permalink<spanclass="token punctuation">:</span> docs<spanclass="token operator">/</span>en<spanclass="token operator">/</span>doc1<spanclass="token punctuation">.</span>html <spanclass="token operator"><</span><spanclass="token operator">!</span><spanclass="token operator">--</span> link to the document that is used <spanclass="token keyword">for</span> site <spanclass="token operator">--</span><spanclass="token operator">></span>
next<spanclass="token punctuation">:</span> doc2 <spanclass="token operator"><</span><spanclass="token operator">!</span><spanclass="token operator">--</span> next doc on the sidebar <spanclass="token keyword">for</span> navigation <spanclass="token operator">--</span><spanclass="token operator">></span>
<spanclass="token operator"><</span><spanclass="token operator">!</span><spanclass="token operator">--</span> don<spanclass="token string">'t include next if this is the last doc; don'</span>t include previous <spanclass="token keyword">if</span> first doc <spanclass="token operator">--</span><spanclass="token operator">></span>
<spanclass="token operator">--</span><spanclass="token operator">-</span></pre><p>Blog posts should be written as markdown files with the following front matter:</p><preclass="prism language-javascript"><spanclass="token operator">--</span><spanclass="token operator">-</span>
title<spanclass="token punctuation">:</span> Blog Post Title
author<spanclass="token punctuation">:</span> Author Name
authorURL<spanclass="token punctuation">:</span> http<spanclass="token punctuation">:</span><spanclass="token operator">/</span><spanclass="token operator">/</span>twitter<spanclass="token punctuation">.</span>com<spanclass="token operator">/</span>author <spanclass="token operator"><</span><spanclass="token operator">!</span><spanclass="token operator">--</span><spanclass="token punctuation">(</span>or some other link<spanclass="token punctuation">)</span><spanclass="token operator">--</span><spanclass="token operator">></span>
authorFBID<spanclass="token punctuation">:</span><spanclass="token number">21315325</span><spanclass="token operator"><</span><spanclass="token operator">!</span><spanclass="token operator">--</span> id to <spanclass="token keyword">get</span> author's picture <spanclass="token operator">--</span><spanclass="token operator">></span>
<spanclass="token operator">--</span><spanclass="token operator">-</span></pre><p>In the blog post you should include a line <code><!--truncate--></code>. This will determine under which point text will be ignored when generating the preview of your blog post. Blog posts should have the file name format: <code>yyyy-mm-dd-your-file-name.md</code>.</p><h2><aclass="anchor"name="using-docusaurus"></a>Using Docusaurus <aclass="hash-link"href="#using-docusaurus">#</a></h2><h3><aclass="anchor"name="run-the-server"></a>Run the Server <aclass="hash-link"href="#run-the-server">#</a></h3><p>To run your website locally run the script:</p><preclass="prism language-javascript">npm run start</pre><p>or</p><preclass="prism language-javascript">yarn run start</pre><p>This will start a server hosting your website locally at <code>localhost:3000</code>. Any changes to configured files will be reflected by refreshing the page, i.e. the server does not need to be restarted to show changes. You may also specify a different port to start your server on by using a <code>--port</code> flag:</p><preclass="prism language-javascript">npm run start <spanclass="token operator">--</span><spanclass="token operator">--</span>port <spanclass="token number">9000</span></pre><h3><aclass="anchor"name="build-static-pages"></a>Build Static Pages <aclass="hash-link"href="#build-static-pages">#</a></h3><p>To create a static build of your website, run the script:</p><preclass="prism language-javascript">npm run build</pre><p>or</p><preclass="prism language-javascript">yarn run build</pre><p>This will generate <code>.html</code> files from all of your docs and other pages included in <code>pages</code>. This allows you to check whether or not all your files are being generated correctly. The build folder is inside Docusaurus's directory inside <code>node_modules</code>.</p><h3><aclass="anchor"name="publishing-your-website"></a>Publishing Your Website <aclass="hash-link"href="#publishing-your-website">#</a></h3><p>Use CircleCI to publish your website whenever your project repo is updated. Configure your circle.yml file in your project repo to run commands to publish to GitHub Pages. An example is shown here:</p><preclass="prism language-yaml"><spanclass="token key atrule">machine</span><spanclass="token punctuation">:</span>
<spanclass="token punctuation">-</span> cd website && npm install && GIT_USER=test<spanclass="token punctuation">-</span>site<spanclass="token punctuation">-</span>bot npm run publish<spanclass="token punctuation">-</span>gh<spanclass="token punctuation">-</span>pages</pre><p>Note that in this case a GitHub user <code>test-site-bot</code> is created to use just for publishing. Make sure to give your Git user push permissions for your project and to set a GITHUB_TOKEN environment variable in Circle if you choose to publish this way.</p><p>If you wish to manually publish your website with the <code>publish-gh-pages</code> script, run the following example command with the appropriate variables for your project:</p><preclass="prism language-javascript">DEPLOY_USER<spanclass="token operator">=</span>deltice GIT_USER<spanclass="token operator">=</span>test<spanclass="token operator">-</span>site<spanclass="token operator">-</span>bot CIRCLE_PROJECT_USERNAME<spanclass="token operator">=</span>deltice CIRCLE_PROJECT_REPONAME<spanclass="token operator">=</span>test<spanclass="token operator">-</span>site CIRCLE_BRANCH<spanclass="token operator">=</span>master npm run publish<spanclass="token operator">-</span>gh<spanclass="token operator">-</span>pages</pre><h2><aclass="anchor"name="more-information"></a>More Information <aclass="hash-link"href="#more-information">#</a></h2><p>For details on how to set up translation support, read <ahref="translation.md"target="_blank">here</a>.
For details on how to set up documentation search, read <ahref="search.md"target="_blank">here</a>.</p></div></article></div><divclass="docs-prevnext"></div></div></div></div><footerclass="nav-footer"id="footer"><sectionclass="sitemap"><ahref="/"class="nav-home"><imgsrc="/img/docusaurus_monochrome.svg"alt="Docusaurus"width="66"height="58"/></a><div><h5>Docs</h5><ahref="