mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
1.9 KiB
1.9 KiB
部署
和 GitBook 生成的文档一样,我们可以直接把文档网站部署到 GitHub Pages 或者 VPS 上。
GitHub Pages
GitHub Pages 支持从三个地方读取文件
docs/目录- master 分支
- gh-pages 分支
我们推荐直接将文档放在 docs/ 目录下,在设置页面开启 GitHub Pages 功能并选择 master branch /docs folder 选项。
!> 可以将文档放在根目录下,然后选择 master 分支 作为文档目录。
GitLab Pages
如果你正在部署你的主分支, 在 .gitlab-ci.yml 中包含以下脚本:
?> .public 的解决方法是这样的,cp 不会无限循环的将 public/ 复制到自身。
pages:
stage: deploy
script:
- mkdir .public
- cp -r * .public
- mv .public public
artifacts:
paths:
- public
only:
- master
!> 你可以用 - cp -r docs/. public 替换脚本, 如果 ./docs 是你的 docsify 子文件夹。
VPS
和部署所有静态网站一样,只需将服务器的访问根目录设定为 index.html 文件。
例如 nginx 的配置
server {
listen 80;
server_name your.domain.com;
location / {
alias /path/to/dir/of/docs;
index index.html;
}
}
Netlify
- Login to your Netlify account.
- In the dashboard page, click New site from Git.
- Choose a repository where you store your docs, leave the Build Command area blank, fill in the Publish directory area with the directory of your
index.html, for example it should be docs if you populated it atdocs/index.html.
HTML5 router
When using the HTML5 router, you need to set up redirect rules that redirect all requests to your index.html, it's pretty simple when you're using Netlify, populate a \redirects file in the docs directory and you're all set:
/* /index.html 200
