README.md 3.0 KB
Newer Older
BaiXuePrincess's avatar
BaiXuePrincess 已提交
1
![Build Status](https://gitlab.com/pages/docusaurus/badges/master/pipeline.svg)
BaiXuePrincess's avatar
BaiXuePrincess 已提交
2

BaiXuePrincess's avatar
BaiXuePrincess 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
---

Example [Docusaurus](https://docusaurus.io/) website using GitLab Pages.

Learn more about GitLab Pages at https://about.gitlab.com/features/pages and the official
documentation https://docs.gitlab.com/ee/user/project/pages/.

---

## GitLab CI/CD

This project's static Pages are built by [GitLab CI/CD](https://about.gitlab.com/product/continuous-integration/),
following the steps defined in [`.gitlab-ci.yml`](.gitlab-ci.yml):

```yaml
image: node:15.12-alpine3.13

stages:
  - test
  - deploy

test:
  stage: test
  script:
  - cd website
  - yarn install
  - yarn build
  except:
    - master

pages:
  stage: deploy
  script:
  - cd website
  - yarn install
  - yarn build
  - mv ./build ../public
  artifacts:
    paths:
    - public
  only:
    - master
```

## Building locally

To work locally with this project, you'll have to follow the steps below:

1. Fork, clone or download this project.
1. Install Docusaurus:

   ```sh
   cd website
   yarn install
   ```

1. Preview your project:

   ```sh
   yarn start
   ```

   Your site can be accessed under http://localhost:3000.

1. Add content.
1. Generate the website (optional):

   ```sh
   yarn build
   ```

   The website will be built under `website/build/`.

Read more at the [Docusaurus documentation](https://docusaurus.io).

## GitLab User or Group Pages

If you have forked this project, in order to use it as your user/group website
served on the root path, you will need to:

1. Change the path of your project to `namespace.gitlab.io`, where `namespace` is
   your `username` or `groupname`. This can be done by navigating to your
   project's **Settings > General** page under the Advanced section.
1. Open `website/siteConfig.js` and change:
   1. The `url` to be `https://namespace.gitlab.io` or your
      [custom domain](https://docs.gitlab.com/ee/user/project/pages/custom_domains_ssl_tls_certification/index.html) of choice.
   1. The `baseUrl` to be '/'.

If you have forked this project, and want to use it under a subpath, you will
need to:

1. Open `website/docusaurus.config.js` and change:
   1. The `url` to be `https://namespace.gitlab.io` or your
      [custom domain](https://docs.gitlab.com/ee/user/project/pages/custom_domains_ssl_tls_certification/index.html) of choice.
   1. The `baseUrl` to be the same as the name of your project.

Read more about the [types of GitLab Pages](https://docs.gitlab.com/ce/user/project/pages/getting_started_part_one.html).

## Did you fork this project?

If you forked this project for your own use, please go to your project's
**Settings > General > Advanced** and remove the forking relationship, which
won't be necessary unless you want to contribute back to the GitLab upstream project.

## Troubleshooting

1. CSS is missing! That means two things:

    Either that you have wrongly set up the CSS URL in your templates, or
    your static generator has a configuration option that needs to be explicitly
    set in order to serve static assets under a relative URL.
BaiXuePrincess's avatar
BaiXuePrincess 已提交
114
    ![image.png](./image.png)