window本地使用Hexo搭建个人博客

转载请表明出处 https://blog.csdn.net/Amor_Leo/article/details/85396596 谢谢

安装git

  • 官网 一路next.(可以自定义安装目录)

安装node.js

  • 官网 一路next.(可以自定义安装目录)

安装hexo

  • 安装hexo
    打开git bash或者(cmd)
npm install -g hexo-cli
  • 初始化Hexo
    打开git bash或者(cmd)
hexo init <folder>
cd <folder>
npm install
├── node_modules #npm依赖包
├── scaffolds #文章等模板
├── source  #博客正文和其他源文件
├── themes   #主题
├── _config.yml   #配置文件
├── db.json   #source解析得到的
├── package.json  #定义了hexo所需要的各种模块
└── package-lock.json
  • 启动服务器
    打开Git Bash
hexo server

打开 http://localhost:4000
在这里插入图片描述

hexo发布至github(coding双部署)

创建github账号

创建仓库

仓库名为:<Github账号名称>.github.io
勾选 Initialize this repository with a README
在这里插入图片描述

添加SSH秘钥

  • 设置Git的user name和email:
git config --global user.name "your name"
git config --global user.email "your email"
  • 打开Git Bash,输入以下命令,回车三次
ssh-keygen -t rsa -C "your email"

打开github,登录,添加的是“id_rsa.pub”(C:\Users\Administrator.ssh\id_rsa.pub)里面的公钥.
在这里插入图片描述
在这里插入图片描述

  • 测试SSH是否成功
ssh -T git@github.com
yes

如果提示:Hi XXX ,You’ve successfully authenticated, but GitHub does not provide shell access. 说明你连接成功了

  • 修改_config.yml(配置文件)
deploy:
  type: git
  repo: git@github.com:你的github账号名称/你的github账号名称.github.io.git
  branch: master
  • 如果你有Coding账号
    添加ssh
    创建仓库 仓库名称是你coding账号名称
    点击Page服务,勾选 一键开启静态 Pages
deploy:
- type: git
  repo: git@github.com:你的github账号名称/你的github账号名称.github.io.git
  branch: master
- type: git
  repo: git@git.dev.tencent.com:你的coding账号名称/你的coding账号名称.git
  branch: master
  • 安装部署插件
npm install hexo-deployer-git --save
  • 部署
hexo clean  
hexo g 
hexo d

hexo clean : 清除缓存
hexo g : 重新生成代码
hexo d : 部署

  • 访问
    https://<Github账号名称>.github.io
    https://<Coding账号名称>.coding.me

主题优化

cd <folder>
git clone https://github.com/iissnan/hexo-theme-next themes/next
  • 修改_config.yml
theme: next
  • NexT个性化设置
    NexT官网

    • 修改\themes\next_config.yml
    #scheme: Muse
    scheme: Mist
    #scheme: Pisces
    #scheme: Gemini
    
  • 部署

hexo clean  
hexo g 
hexo d
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值