Publish the Site
{.docImage}
Next, we'll learn how to publish the site to the WWW for everyone to browse! For the purpose of the tutorial, we'll use GitHub pages to host our website. But you can use any static file hosting service that you want, e.g. Netlify, Amazon S3, etc.
Put the Site Online
Kill the web server first by pressing Cmd + C or Ctrl + C depending on your operating system.
In website/siteConfig.js
, fill in the following fields:
const siteConfig = {
...
url: 'https://USERNAME.github.io', // Replace USERNAME with your GitHub username.
baseUrl: '/docusaurus-tutorial/', // The name of your GitHub project.
projectName: 'docusaurus-tutorial', // The name of your GitHub project. Same as above.
organizationName: 'USERNAME' // Your GitHub username.
...
}
In the
website
directory, runnpm run build
oryarn build
. 명령어가 실행되면build
디렉토리가website
디렉토리 아래 생성됩니다. 생성된 디렉토리에는 작성한 문서가.html
파일로 생성되며pages
디렉토리 안에 있던 콘텐츠도 같이 생성됩니다. Make sure thebuild
directory is there before running the next step.Replace
<GIT_USER>
with your GitHub username and run the following command.$ GIT_USER=<GIT_USER> CURRENT_BRANCH=master USE_SSH=true npm run publish-gh-pages
The built code will be pushed to the gh-pages
branch of your repository.
- Go to
https://USERNAME.github.io/docusaurus-tutorial/
and view your site in action!
Note that when you run
npm run start
again, thebaseUrl
will now be part of the path.