在本地构建并将VuePress站点推送到Github Pages

问题描述 投票:1回答:1

无法弄清楚如何使用Github作为VuePress站点源代码控制和deploying it to Github Pages的工作流程。

当我第一次运行deploy.sh时,它在init命令周围给了我一个Github证书错误并且没有初始化一个新的repo(我已经有一个repo设置所以不确定init中的deploy.sh命令是否是必需的。后续运行的deploy.sh结果没有错误。

**问题:**不幸的是,当我访问my Github Pages site时,它没有使用VuePress模板。

我觉得我有: - 文件夹结构错误 - baseconfig.js中设置错误 - 相关文件夹在deploy.sh中不正确

有人可以关注这个并给出一些反馈吗?谢谢。

供你参考

本地机器的文件夹结构:

user@system:~/powerDocs$ tree
.
├── deploy.sh
├── docs
│   └── README.md
├── node_modules
│   └── yarn
│       ├── bin
│       │   ├── yarn
│       │   ├── yarn.cmd
│       │   ├── yarn.js
│       │   ├── yarnpkg
│       │   └── yarnpkg.cmd
│       ├── lib
│       │   ├── cli.js
│       │   └── v8-compile-cache.js
│       ├── LICENSE
│       ├── package.json
│       └── README.md
├── package.json
├── package-lock.json
└── README.md

5 directories, 15 files

deploy.sh的内容:

#!/usr/bin/env sh

# abort on errors
set -e

# build
vuepress build

# navigate into the build output directory
cd docs/.vuepress/dist

# if you are deploying to a custom domain
# echo 'www.example.com' > CNAME

git init
git add -A
git commit -m 'deploy'

# if you are deploying to https://<USERNAME>.github.io
# git push -f [email protected]:SeaDude/SeaDude.github.io.git master

# if you are deploying to https://<USERNAME>.github.io/<REPO>
git push -f [email protected]:SeaDude/powerDocs.git master:gh-pages

cd -

我用chmod +x deploy.sh创建了deploy.sh可执行文件。运行./deploy.sh给我以下输出:

user@system:~/powerDocs$ ./deploy.sh 

 WAIT  Extracting site metadata...
[12:05:53 PM] Compiling Client
[12:05:53 PM] Compiling Server
(node:15590) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
[12:05:57 PM] Compiled Server in 3s
[12:05:59 PM] Compiled Client in 6s
 WAIT  Rendering static HTML...

 DONE  Success! Generated static files in .vuepress/dist.

Reinitialized existing Git repository in /home/powerDocs/docs/.vuepress/dist/.git/
On branch master
nothing to commit, working directory clean

这是config.js的内容:

module.exports = {
  title: "PowerDocs",
  description: "Where functions go to frolic.",
  base: "/powerDocs/",

  themeConfig: {
    nav: [
      { text: "Home", link: "/" }
    ],
    sidebar: [
      '/'
    ]
  }
};
github github-pages vuepress
1个回答
0
投票

你检查了你的dist文件夹,看看实际输出的是什么?该错误使得在构建之后似乎没有要提交的文件。

我在本地有几乎相同的设置,并没有遇到这个问题,唯一的区别是我运行构建的命令是yarn docs:build

© www.soinside.com 2019 - 2024. All rights reserved.