如何搭建Hexo博客,并发布到github上

1、安装好git

2、安装好npm、node

3、切换npm的源,现在阿里的cnpm不行了,要切换成新的:

复制代码
npm config set registry https://registry.npmmirror.com
npm config get registry

4、安装hexo-cli

复制代码
npm install -g hexo-cli

查看是否安装成功: 
hexo -v

5、博客初始化:创建一个文件夹,进入该文件夹

复制代码
 hexo init
在博客文件夹的根目录右键打开 GitBash
hexo s
在浏览器输入localhost:4000查看

新建文章

hexo new "标题"

切换主题

去hexo模板市场 更换,然后放进来themes文件夹,修改_config.yml里面的themes配置即可

发布到github上

1、npm install --save hexo-deployer-git

2、在github创建仓库,名为:xxx.github.io xxx是你的github名字

3、修改_config.yml

复制代码
# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://你的github名.github.io/
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

...

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: git
  repository: https://github.com/你的github名/你的github名.github.io.git
  branch: master

修改代码后推送到github

hexo d

相关推荐
OpenTiny社区1 小时前
生成式UI,AI交互的下一个十年?OpenTiny在QCon 2026的深度分享
前端·开源·github
存在X2 小时前
前端自动化编译Jenkins
前端·github
逛逛GitHub3 小时前
Kimi 2.6 来了!一次性发了 5 个王炸,还有一个 Agent 版微信?
github
Hical_W6 小时前
C++ 也能优雅写 Web?5 分钟用 Hical 搭建 REST API
开发语言·c++·github
CoderJia程序员甲7 小时前
GitHub 热榜项目 - 日榜(2026-04-20)
ai·大模型·llm·github·ai教程
Java后端的Ai之路7 小时前
SSH配置与GitHub项目拉取操作指南
elasticsearch·ssh·github·公钥
纪伊路上盛名在7 小时前
如何跨设备访问我们VSCode中GitHub Copilot 的聊天记录?
vscode·github·copilot·工作流
第一程序员17 小时前
数据工程 pipelines 实践
python·github
CV工程师(Ctrl)18 小时前
OpenClaw 安装与飞书接入(2026-04-19)
node.js·github·飞书·火山引擎·openclaw
历程里程碑18 小时前
2. Git版本回退全攻略:轻松掌握代码时光机
大数据·c++·git·elasticsearch·搜索引擎·github·全文检索