Minhal's Blog

Back

年轻爱折腾,从wordpress—>typecho—>hexo,追求越来越轻量。

网站托管于zeit+github,(zeit真香,速度相对快一些)

hexo搭建#

安装git#

sudo apt-get install git
plaintext

nodejs#

sudo apt-get install nodejs
sudo apt-get install npm
plaintext

hexo#

npm install -g hexo-cli
plaintext

初始化hexo

blog是文件名

hexo init blog
plaintext

进入blog文件

npm install
plaintext

直接通过下面命令本地查看效果

hexo g
hexo server
plaintext

github#

github 新建公开仓库

githubname.github.io

生成ssh添加到github#

git config --global user.name "yourname"
git config --global user.email "youremail"

##检查
git config user.name
git config user.email

ssh-keygen -t rsa -C "youremail"
plaintext

生成.ssh 文件

id_rsa.pub复制到github—>setting—>SSH keys

下面命令检查成功与否

ssh -T git@github.com
plaintext

部署到github#

_config.yml文件打开,最下面修改

# Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: git@github.com:githubname/githubname.github.io.git
  branch: master
plaintext

安装deploy-git

npm install hexo-deployer-git --save
plaintext
# 清除生成
hexo clean
#生成静态文件
hexo g
#部署到github
hexo d
plaintext

添加站点地图#

npm install hexo-generator-sitemap --save #sitemap.xml google
npm install hexo-generator-baidu-sitemap --save #baidusitemap.xml百度
plaintext

themes\next\layout\_partials\head.swing中添加百度站长验证代码

谷歌在https://search.google.com/search-console 添加站点信息

_config.yml 添加

sitemap:
path: sitemap.xml
baidusitemap:
path: baidusitemap.xml
plaintext

RSS#

npm install hexo-generator-feed

###_config.yml

plugins: hexo-generator-feed
#Feed Atom
feed:
    type: atom
    path: atom.xml
    limit: 20
plaintext

zeit托管#

为什么用zeit?

github国内访问相对较慢,所以直接托管到了zeit上面。

注册#

通过ZEIT使用github登陆

导入#

Import Project 导入github博客仓库。

部署#

接着全部默认即可。

最后生成一个xxx.now.sh域名

域名修改#

cname 添加记录绑定自己域名

详细介绍可以参考帮助文档

valine#

  • 注册LeanCloud
  • 创建新应用
  • 设置 应用key 查看APP ID APP KEY
  • 安全中心添加博客域名
  • 修改主题的配置文件添加id 和 key
hexo+github+zeit Blog
https://minhal.me/blog/hexo-github-zeit-blog
Author Minhal
Published at 2020年5月8日
Comment seems to stuck. Try to refresh?✨