首先要安装一些必要的软件
iterm2:https://iterm2.com/PowerShell:https://docs.microsoft.com/git --version 没有输出版本号,那么就代表你需要安装git:https://git-scm.com/.pkg包,Windows安装.msi包,选择32位还是64位可以看:百度经验node -v 如果输出以下内容代表 Node.js 安装完好:node -v
v14.17.5 // <-- 这里的版本号应该是你安装的那个
接下来我们开始创建项目
cd命令:百度经验mkdir命令:https://www.runoob.com/(PS:文档中方括号内的参数代表可选参数)mkdir blog
cd blog
git init
npm init
以上4个命令分别代表:
blog的文件夹blog文件夹git(后面部署时会用到)npm,会在blog目录下生成package.json在输入npm init之后,命令行会进入提示阶段,可以给项目起一个任意的name,然后一路回车即可
vuepress文档:https://v2.vuepress.vuejs.org/package.json是一个json类型的文件,需要满足其格式约束,你可以把内容粘贴到:https://jsonlint.com/ 来验证内容格式的正确性npm install @calibur/vuepress-theme-eva
touch vuepress.config.ts
type nul > vuepress.config.ts
vuepress.config.ts:import { defineUserConfig } from 'vuepress'
import type { DefaultThemeOptions } from 'vuepress'
export default defineUserConfig<DefaultThemeOptions>({
theme: '@calibur/eva',
title: '博客标题',
themeConfig: {
author: '你的名字'
}
})
ctrl + c
npm run docs:dev
README.md无法展示了,那是因为这个主题默认不展示README.md,但你也不能删除它,我们可以创建其他文件来写博客README.md同级目录下,创建任意文件名.md来写新的博文,重启博客就可以看到了markdown语法参见:markdown手册---
title: 页面的标题
description: 页面的描述
---
ssh key:https://docs.github.com/ssh key到github:https://docs.github.com/github pages仓库:https://docs.github.com/github repo关联起来:git remote add origin git@github.com:你的github昵称/你的github昵称.github.io.git
git status
git add -A
git commit -m "first push"
git push origin master
添加自动化部署脚本:https://v2.vuepress.vuejs.org/
需要注意的是:
master,上面文档中的配置样例第6行指定的是main分支,所以要把main改成masteryarn docs:build,和我们的npm run docs:build是一样的效果,无需修改配置github pages发布源:https://docs.github.com/,将分支改为:gh-pages,目录为:/(root)
配置完成后,以后每当本地提交代码,git 都会自动更新你的修改到个人博客站点