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

相关推荐
千寻girling21 分钟前
一份不可多得的《微服务》教程
后端·面试·github
霜落长河2 小时前
用Gemini提升React代码调试效率的教程
github
英勇无比的消炎药4 小时前
TinyRobot 源码深度分析:OpenTiny 的 AI 对话组件库
前端·vue.js·github
逛逛GitHub21 小时前
慢慢吃掉你的 Claude Code,在终端里养一只黑洞。
github
jump_jump1 天前
为了重玩金庸群侠传,我研究了一下 Ruffle 怎么复活 Flash
游戏·rust·github
LinXunFeng2 天前
Obsidian - 使用 Share Note 分享笔记并自部署
前端·笔记·github
DayDaydream2 天前
7 天涨了 8000+ Star,Agent Reach 想给 AI 装上互联网眼睛
github
天衍四九3 天前
Git从0到实战(四):冲突解决与版本回退 —— 别怕,出错了也能救
github
大刚测试开发实战3 天前
如何内网穿透访问本地私有化部署的TestHub
前端·后端·github
uhakadotcom4 天前
在python 的 工程化架构中 ,什么是 薄包装器层?
后端·面试·github