网站部署教程

网站部署教程

1.工具安装:nodejs git

安装node.js长期版,自动配置环境变量

安装git

node.js链接 git链接

nodejs链接 https://link.zhihu.com/?target=https%3A//nodejs.org/zh-cn
git链接 https://git-scm.com/downloads

验证安装

1
2
3
git --version
node -v
npm -v

git镜像设置

1
npm config set  registry https://registry.npmmirror.com

git设置用户名,邮箱(github的用户名及邮箱)

1
2
git config --global user.name "自己的GitHub用户名"
git config --global user.email "自己的GitHub邮箱"

验证用户名邮箱

1
git config --global -l

2.连接github

创建ssh密钥

1
ssh-keygen -t rsa -C "自己的GitHub邮箱"

进入C:\Users\MIR.ssh复制id_rsa.pub内容
github中个人setting-SSH and GPG keys点击New SSH key,粘贴到key中,title随便设置,add ssh key
验证连接

1
ssh -T git@ssh.github.com //输入yes,显示“Hi xxx! You've successfully……” 即连接成功

3.创建github创建仓库

仓库名:用户名.github.io, 勾选readme

4.下载hexo并本地部署

新建文件夹Hexo-Blog 右键git bash here
安装hexo

1
npm install -g hexo-cli

创建博客文件并初始化

1
2
hexo init
npm install

本地启动预览

1
2
hexo g
hexo s

5.部署 Hexo 到 GitHub Pages

安装 hexo-deployer-git

1
npm install hexo-deployer-git --save

修改 _config.yml 文件末尾的 Deployment

1
2
3
4
deploy:
type: git
repository: git@ssh.github.com:用户名/用户名.github.io.git
branch: main

生成本地页面

1
hexo d

(完成)

6.更改主题(可选)

下载主题(以next主题为例)next主题
下载并解压到theme文件夹下,并将hexo-theme-next更名为next
修改 _config.yml 文件的theme: next

1
theme: next

git bash here中安装hexo-renderer-swig插件

1
npm install hexo-renderer-swig --save

清除缓存并重新生成

1
2
3
4
5
hexo clean
hexo generate
hexo s --debug

或者 hexo clean && hexo g && hexo s 一步完成

7.修改全局配置文件*config.yml(可选)

1
2
3
4
5
6
titile: 博客名
subtitle: "副标题"
description: "描述"
author: 作者
language: zh-CN
timezone: Asia/Shanghai

注意事项

1.github仓库名必须与用户名相同

2.*config.yml文件修改时的“:”后需加空格

3.主题推荐:

1.Butterfly 2.Matery 3.Yilia 4.Icarus 5.Fluid 6.Melody
7.NexT (Rebirth) 8.Cactus 9.Hiero 10.Apollo


网站部署教程
http://www.example.com/2025/04/01/博客部署教程/
作者
MIR
发布于
2025年4月1日
许可协议