Hexo个人博客搭建(Windows)

一、git工具安装

官网:https://git-scm.com/

安装后鼠标右键可以看到就是安装成功了。

1

二、node.js安装

官网:https://nodejs.org/zh-cn
安装后,鼠标右键选择Open Git Bash here

1
node -v                                                     #查看node版本
1
npm -v                                                       #查看npm版本
1
npm install -g cnpm --registry=http://registry.npm.taobao.org   #安装cnpm

遇到的问题:npm安装时一直idealTree:npm: sill idealTree buildDeps
解决方法:

1
npm config set registry https://registry.npmmirror.com
1
npm config get registry                                   #查看是否安装成功

然后接着:

1
cnpm install -g hexo-cli                                    #安装hexo框架 
1
hexo -v                                                     #查看hexo版本

三、hexo配置和初始化

然后创建blog目录

1
cd blog                                                     #进入blog目录
1
hexo init                                              #生成博客 初始化博客
1
hexo s                                                    #启动本地博客服务

本地访问地址:http://localhost:4000/ ,不能访问就输入:

1
hexo s -p 4001

地址就变成:http://localhost:4001/Crtl+C退出。

这里

1
hexo n "我的第一篇文章"                                        #创建新的文章

四、Github设置

在我们的github主页新建一个仓库,名字一定要是:YourGithubName.github.io

然后在blog目录中找到_config.yml文件,打开它,在最后的部分修改:

1
2
3
4
5
6
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/YourGithubName/YourGithubName.github.io.git
branch: main

(注意缩进两格和冒号后面一格)

1
hexo d                                                 #部署到Github仓库里

访问这个地址可以查看博客:https://YourGithubName.github.io/

主题美化:(以yilia为主题)

1
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia

修改hexo根目录下的‘ _config.yml’ 文件 : theme: yilia

五、遇到的问题

(1)hexo博客中插入图片失败

1、将_config.yml 文件中的post_asset_folder 选项设为 true 来打开。

2、typora(Markdown编辑器)图像设置:hexo博客中插入图片失败——解决思路及个人最终解决办法_hexo 文章插入图片失败-CSDN博客

3、插件下载:

1
npm install https://github.com/CodeFalling/hexo-asset-image --save

4、注意格式:去掉前面的路径

2

(2)github上传问题

1
git init
1
git add .
1
git commit -m "1"
1
git branch -M main
1
git remote add origin xxxx.git
1
git push -u origin main

如果不行,就强制上传:

1
git push -u origin main -f

问题:文件太大传不上去,报错

解决方法:缩小文件夹,然后删掉.github.git文件重新上传就可以了。

扫一扫,分享到微信

微信分享二维码
  • Copyrights © 2024 John Doe
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信