如何创建个人博客
# 说明
本来使用docsify
框架搭建,github pages
部署的,但是由于一些问题,原来的博客被搞坏了。于是又花了两天时间用vuepress-theme-vdoing (opens new window)主题为框架,但是采用的是Veal98/cs-wiki (opens new window)框架,使用vercel部署。
简单来说,本地内容要可以让别人看到,必须上传到一个仓库里,这个仓库就是github
,而vercel
是用来将vuepress-theme-vdoing (opens new window)框架生成网页。
# 步骤
- 克隆内容 (opens new window)到本地,那就拥有了主题框架,然后写自己的md文件。
npm install
,npm run dev
,生成本地网页,进行预览。- 上传到github仓库上。如何上传,参考Github——git本地仓库建立与远程连接(最详细清晰版本!附简化步骤与常见错误)github本地仓库和远程仓库 (opens new window)
- 建立仓库
- 上传到仓库,参考git的add、commit、push的详细介绍 (opens new window)
- 打开
vercel
,进行部署。遇到
错误
Error: No Output Directory named "public" found after the Build completed. You can configure the Output Directory in your Project Settings.
解决
在.vuepress/config.js
文件中module.exports
中添加dest: './public',
然后就可以部署成功。可以直接通过网址访问。
# 一些错误
- 上传项目到仓库的时候,遇到以下错误:
error
OpenSSL SSL_read: Connection was reset, errno 10054
这是你本地网络的问题,github
的服务器地址有时候会被拦截。
- github令牌过期,新建令牌 Github创建个人访问令牌教程 (opens new window)
# 具体修改
在
config.js
文件中的nav
是设置导航栏的,通过对应的link: '/pages/c8820d/'
来跳转到相应的文件夹,例如text: '计算机网络', link: '/pages/net/'
,点击计算机网络
后,就跳转到/pages/net/
这个文件的目录之下。index
文件用来设置主页面。确定目录结构
nav
之后,再写文件,就不需要更改目录,除非要开辟新的栏目。
# 上传代码
git add .
git commit -m "first commit"
git remote add origin https://github.com/xxxx/xxx.git(https://github.com/xxxx/xxx.git就是仓库地址 )
git push -u origin main
git add .
git commit -m "first commit"
git push -u origin main