如何搭建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

相关推荐
勤劳打代码9 分钟前
步步为营 —— Github Connection refused 分层诊断
github
寻月隐君1 小时前
深入解析 Rust 的面向对象编程:特性、实现与设计模式
后端·rust·github
qianmoQ16 小时前
GitHub 趋势日报 (2025年05月31日)
github
油泼辣子多加16 小时前
2025年06月06日Github流行趋势
github
粥里有勺糖17 小时前
视野修炼-技术周刊第122期 | 发光图片制作
前端·javascript·github
qianmoQ17 小时前
GitHub 趋势日报 (2025年06月05日)
github
小馒头君君17 小时前
3 个优质的终端 GitHub 开源工具
github
MarkHD21 小时前
AI编程助手入门指南:GitHub Copilot、Cursor与Claude的安装与基础使用
github·copilot·ai编程
追逐时光者1 天前
2个 GitHub 实用辅助神器,帮你快速了解和上手 GitHub 开源项目(附带 GitHub 加速神器)!
github
寻月隐君1 天前
Web3实战:Solana CPI全解析,从Anchor封装到PDA转账
后端·web3·github