利用Hexo在Github搭建个人博客

2021-03-03  本文已影响0人  SuperGino

本教程是在Mac环境下操作

一、安装配置Hexo
利用npm命令安装

npm install -g hexo-cli         #-g参数表示全局安装

如果看到提示:Unsupported engine for hexo-cli@4.2.0: wanted: {"node":">=10.13.0"} (current: {"node":"8.17.0","npm":"6.13.4"})
出现上面提示的原因是因为node版本过低,可以执行下面方法升级node

node -v  #先查看本机node.js版本:
sudo npm install -g n  #安装node管理器n
sudo n stable # 升级最新稳定版本

二、创建博客存放文件夹,并初始化

mkdir imBlog   #imBlog是目录名称,目录名称位置可以自己随意指定
hexo init imBlog   # 初始化
cd imBlog
看到提示Start blogging with Hexo!就是成功初始化了

三、本地启动和预览

hexo g              # 生成静态页面 hexo generate
hexo s              # 启动本地服务器 hexo server

本地预览
启动成功后,浏览器访问: http:localhost:4000

四、部署到github

$ npm install hexo-deployer-git --save  #安装自动部署插件

修改github配置


修改repository为自己用户名
设置source路径
修改_config_yml 文件,配置发布信息
deploy:
    type: git
    branch: master
    repo: https://github.com/Ginoooo/GinoBlog.git
hexo d -g                       # hexo deploy 生成部署合并为一条命令

四、使用主题NEXT

git clone https://github.com/theme-next/hexo-theme-next themes/next
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: hexo-theme-clean-dark #landscape

# 打开NEXT阅读次数统计
busuanzi_count:
  enable: true
  total_visitors: true   #统计访客数
  total_visitors_icon: user
  total_views: true    #统计访问数
  total_views_icon: eye
  post_views: true   #统计文章阅读数
  post_views_icon: eye

四、打开域名即可看到新建的bolg
https://ginoooo.github.io/

五、使用自定义域名访问博客

ping xxx.github.io
获取ip值 QQ20210303-145837.png QQ20210303-145847.png

发布新文章
hexo publish "xxxxx"

上一篇下一篇

猜你喜欢

热点阅读