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

相关推荐
飞乐鸟11 分钟前
Github 10.4k Star!一款开源免费高效的Markdown编辑器!
github
玄同76521 分钟前
让 Trae IDE 智能体 “读懂”文档 Excel+PDF+DOCX :mcp-documents-reader 工具使用指南
人工智能·git·语言模型·gitee·github·ai编程·mcp
lyx_20161 小时前
火山引擎GitHub CI + 对象存储 + CDN静态资源网站部署总结
ci/cd·github·火山引擎
CoderJia程序员甲12 小时前
GitHub 热榜项目 - 日榜(2026-01-22)
ai·开源·大模型·github·ai教程
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 日榜(2026-01-25)
开源·大模型·llm·github·ai教程
CoderJia程序员甲20 小时前
GitHub 热榜项目 - 日榜(2026-01-24)
git·ai·开源·llm·github
TTGGGFF1 天前
告别繁琐命令行:自研多线程 SSH 极速文件传输助手(附 GitHub 源码)
运维·ssh·github
普通网友2 天前
远程配置 VsCode:Github Copilot 安装成功却无法使用?细节避坑
vscode·github·copilot
极智-9962 天前
GitHub 热榜项目-日榜精选(2026-01-24)| AI智能体工具、Python生态等 | remotion、VibeVoice、goose等
人工智能·python·github·ai智能体·大模型部署·语音ai
github.com/starRTC2 天前
Claude Code中英文系列教程17:将Claude Code集成在GitLab工作流里面
git·gitlab·github