hexo blog搭建

安装部署

安装nvm nodejs

https://github.com/creationix/nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm install node
nvm use 9.0.0

安装运行hexo

npm install -g cnpm --registry=https://registry.npm.taobao.org  #淘宝定制命令cnpm替换,使用淘宝源

cnpm install hexo-cli -g
hexo init blog
cd blog
cnpm install
hexo server --debug  # 运行

自动部署github

npm install hexo-deployer-git --save
在配置文件_config.xml中作如下修改
deploy:
  type: git
  repo: [email protected]:hgleagle/hgleagle.github.io.git
  branch: master

hexo clean #先清除
hexo generate #生成静态文件
hexo deploy # 部署,实现如下命令

deploy实际实现如下工作

cp -R public/* .deploy_git/
cd .deploy_git
git add .
git commit -m “update”
git push origin master

注册绑定自定义域名

namesilo 注册申请域名,只需要 35 块,赠送 whois 隐私保护
到 dnspod 绑定域名服务器,创建两个 A 绑定 IP,一个 CNAME 记录绑定域名
https://www.namesilo.com/create_account.php

配置

配置站点 _config.yml 使用next主题

基础配置参考 http://theme-next.iissnan.com/

#### 文章目录显示
npm i hexo-generator-json-content --save

标签云, 分类

hexo new page tags
hexo new page categories

评论

注册添加disqus

disqus:
  shortname: https-hgleagle-github-io # 修改next/_config.yml

RSS

cnpm install hexo-generator-feed

avatar、qrcode

使用七牛图床,或者本地在 source 下创建 img 目录保存图片,修改_config.yml添加外链或路径

阅读次数

注册leancloud 帐号,创建 Counter ,拷贝 appid、appkey 到下面配置, 安全中心添加 web 安全域

leancloud_visitors:
  enable: true
  app_id: xxx
  app_key: xxx

搜索

# 安装
npm install --save hexo-generator-search

# 修改站点_config.yml增加
search:
  path: search.xml
  field: post
  format: html
  limit: 10000

Sitemap for SEO

参考
Hexo-NexT-主题的-SEO优化
Hexo博客收录百度和谷歌-基于Next主题

  • 生成 sitemap 提交到 google、 baidu 进行站点验证,修改配置文件
# 安装
cnpm install hexo-generator-sitemap
cnpm install --save hexo-generator-baidu-sitemap

# 修改站点config
# 提交给谷歌搜素引擎,SEO优化开启配置是一样的
sitemap:
    path: sitemap.xml
# 提交百度搜索引擎   
baidusitemap:
    path: baidusitemap.xml 

通过搜索引擎查找 site:jasonfly.me 检查是否被收录

  • 添加 robots.txt 协议
  • 修改 next 主题 siderbar.swig footer.swig 增加 rel="external nofollow",意思是告诉引擎这些是外链,不要爬取
  • 默认 permalink 太长,缩短成 :title
  • 修改 scaffolds 中 post.md 模板增加 keywords: description:

猜你喜欢

转载自blog.csdn.net/hgleagle/article/details/88380902