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

相关推荐
uhakadotcom1 小时前
PyTorch 2.0 一行代码加速模型,简单易懂的基础介绍和实用示例
后端·面试·github
Andy3222 小时前
027 期 数据安全新招!你的数据守护神来了?
安全·github
may_一一2 小时前
GitHub配置密钥
github
长风清留扬2 小时前
3款本周高潜力开源AI工具(多模态集成_隐私本地化)
人工智能·开源·github·自动翻译
GoGeekBaird3 小时前
69天探索操作系统-第59天:容器化内部机制 - 深入探讨命名空间实现
后端·操作系统·github
x-cmd4 小时前
[250416] GitHub Action 新升级,支持 Windows on Arm
arm开发·windows·github·github action
Sherry Wangs17 小时前
GitHub实用手册
github
uhakadotcom18 小时前
PyTorch 2.0:最全入门指南,轻松理解新特性和实用案例
后端·面试·github
LTPP18 小时前
掌握Rust Web开发的未来:Hyperlane框架全方位教程 🎓🔧
前端·后端·github
uhakadotcom19 小时前
Apache APISIX入门指南:快速理解与实战示例
后端·面试·github