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

相关推荐
一条Go9 分钟前
开源新生代雷达 · 第 15 期
github
OpenTiny社区1 小时前
我用Vue 100%复制DeepSeek开源的网页App,代码更少,功能还更多!
前端·vue.js·github
Bigger2 小时前
我扒了 GitHub Trending 前 20,8 个在做同一件事:给 Coding Agent 造基础设施
开源·github·ai编程
徐小夕3 小时前
MedDoc AI:把临床书写、协作、质控、知识问答装进一个工作台
前端·vue.js·github
cong_3 小时前
🐟 我把摸鱼岛重写了!现在群聊还能装进一张表格
前端·后端·github
wflynn4 小时前
GitHub 今日推荐|rust-anything:录制真实输入输出,渐进式重写热点函数到 Rust
rust·开源·github·cli·claude-code·agent-skills
wflynn4 小时前
GitHub 日榜趋势速报 | 2026-11-17
开源·github
敢敢是只喵i19 小时前
OpenAPI 里有两个 quantity,审批规则到底在比哪个?
github
七分辣度19 小时前
GitHub/Git 常用命令及使用场景
git·github
dong_junshuai19 小时前
每天一个开源项目#160 LoopForge:把Agent交付拆成可退回的验收流程
github