Hexo 个人博客 常用功能配置


一、hexo 添加站内搜索功能

  1. 安装搜索插件

    1
    npm install hexo-generator-searchdb --save
  2. 修改站点配置

    1
    2
    3
    4
    5
    6
    # Local_search
    search:
    path: search.xml
    field: post
    format: html
    limit: 10000
  3. 修改主题配置

    1
    2
    local_search:
    enable: true
  4. 清除缓存,预览主题效果

    1
    2
    3
    4
    5
    hexo clean

    hexo g

    hexo s
  5. Next主题 配置

    1
    2
    3
    4
    5
    6
    Next主题有多种隐藏模式,默认Mist

    # Schemes
    #scheme: Muse
    scheme: Mist
    #scheme: Pisces

二、hexo 添加Tags

  1. 新建Tags页面

    1
    hexo new page tags
  2. 找到tags文件位置,打开并修改index.md

    1
    2
    3
    4
    5
    6
    ---
    title: Tags
    date: 2019-03-28 15:28:16
    type: "tags"
    comments: false
    ---
  3. 修改主题配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    menu:
    home: / || home
    #about: /about/ || user
    tags: /tags/ || tags
    #categories: /categories/ || th
    archives: /archives/ || archive
    #schedule: /schedule/ || calendar
    #sitemap: /sitemap.xml || sitemap
    #commonweal: /404/ || heartbeat

tags: /tags/ || tags前面的#去掉

三、添加百度 sitemap

  1. 生成站点地图

    • 安装百度站点地图插件

      1
      npm install hexo-generator-baidu-sitemap --save
    • 修改配置文件(根目录下的_config.yml)

      1
      2
      3
      4
      5
      6
      #站点地图
      Plugins:
      - hexo-generator-baidu-sitemap

      baidusitemap:
      path: baidusitemap.xml
    • 查看结果
      运行命令 hexo g,进入public目录,发现里面有baidusitemap.xml文件即可

  2. 百度站长平台提交网站链接

    • 百度站长平台 > 我的网站 > 站点管理 中添加我的网站链接;
    • 在第二步验证网站时选择文件验证,并下载验证文件放到博客项目代码下的根目录下
    • 在网页抓取 > 链接提交 中按步骤提交

四、添加RSS订阅功能

  1. 安装hexo-generator-feed插件

    1
    npm install hexo-generator-feed --save
  2. 修改配置文件(根目录下的_config.yml)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    #RSS订阅
    plugin:
    - hexo-generator-feed
    #Feed Atom
    feed:
    type: atom
    path: atom.xml
    limit: 20
    hub:
    content:
    content_limit:
    content_limit_delim: ' '

参考文章