Luck、Time

  • 主页
  • 小说鉴赏
  • 专业笔记
  • 个人简介
所有文章 友链 关于我

Luck、Time

  • 主页
  • 小说鉴赏
  • 专业笔记
  • 个人简介

Hexo 个人博客搭建 --持续优化

2017-10-20

Hexo是一个开源的静态博客生成器,用node.js开发,作者是台湾大学生tommy351。


Hexo 安装

Git 安装

git下载地址

Node.js 安装

Node.js下载地址

Hexo 安装

Hexo 官方文档

1
npm install -g hexo-cli


创建项目及主题安装

创建项目

具体方法参考官网 建站

安装主题

安装方法

主题github地址: https://github.com/litten/hexo-theme-yilia

1
2
3
4
cd 项目
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
修改 根目录的 _config.yml 文件
theme: yilia

其他主题介绍

其他hexo主题


插件选择安装

更多插件介绍

更多hexo插件


持续优化

设置Yilia菜单

1
2
3
4
5
6
7
8
9
10
11
打开 themes/_config.yml
# Header
menu:
主页: /
阅读笔记: /tags/阅读笔记/
电影观感: /tags/电影观感/
专业知识: /tags/专业知识/
关于更多: /aboutme
对文章设置标签tag,从而使点击按钮时。自动筛选出相应文章列表.
关于更多,可以自定义页面。

设置tags

1
npm install --save hexo-generator-tag 框架默认已经安装

post 文章部分设置

1
2
tag:
- 开发方式

设置目录

1
npm install --save hexo-generator-tag 框架默认已经安装
1
2
3
4
5
6
7
post 结构
title: Hexo 个人博客搭建 --持续优化
data: 2017年8月17日10:00:09
tag:
- 开发方式
toc: true // 是否显示目录

RSS 设置

正确设置RSS

设置展示更多

1
<!--more-->

主题设置

1
2
3
4
5
6
themes/yilia/_config.yml
# 文章太长,截断按钮文字
excerpt_link: 展开全文
# 文章卡片右下角常驻链接,不需要请设置为 false
# show_all_link: '展开全文'
show_all_link: false

文章排序

文章按照更新时间排序: 项目根目录/_config.yml

1
2
3
4
5
index_generator:
path: ''
per_page: 10
#order_by: -date
order_by: -updated

参考:

hexo-generator-index

插件地址:https://github.com/hexojs/hexo-generator-index

Installation

1
$ npm install hexo-generator-index --save

Options

1
2
3
4
index_generator:
path: ''
per_page: 10
order_by: -date
  • path: Root path for your blogs index page. (default = ‘’)
  • per_page: Posts displayed per page. (0 = disable pagination)
  • order_by: Posts order. (Order by date descending by default)

自定义打赏功能

yilia打赏功能默认是支付宝和微信支付,也可以自定义其他。

此次定义的是 thanks。仅表示谢谢

打开主题 themes/yilia/layout/article.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<div class="reward-box">
<% if(theme.alipay) {%>
<div class="reward-box-item">
<img class="reward-img" src="<%= theme.alipay%>">
<span class="reward-type">支付宝</span>
</div>
<% } %>
<% if(theme.thanks) {%>
<div class="reward-box-item">
<img class="reward-img" src="<%= theme.thanks%>">
<span class="reward-type">谢谢你哦</span>
</div>
<% } %>
<% if(theme.weixin) {%>
<div class="reward-box-item">
<img class="reward-img" src="<%= theme.weixin%>">
<span class="reward-type">微信</span>
</div>
<% } %>
</div>

google 分析 GA 代码的添加

链接跳转

主题中添加天气

step1:找到需要安装插件的位置

step2:我使用的是 新知天气的一个扩展插件 https://www.seniverse.com/widget/get

step3:配置新知天气的展示效果,以达到自己的期望效果

step4:将生成的代码放置到想要 展示html的位置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
复制下面代码粘贴到页面代码的合适位置。第一行的div为插件的容器元素,你也可以通过自定义的CSS来控制其样式和位置,但请不要手动修改其id,否则插件将无法正常使用。
<div id="tp-weather-widget"></div>
<script>(function(T,h,i,n,k,P,a,g,e){g=function(){P=h.createElement(i);a=h.getElementsByTagName(i)[0];P.src=k;P.charset="utf-8";P.async=1;a.parentNode.insertBefore(P,a)};T["ThinkPageWeatherWidgetObject"]=n;T[n]||(T[n]=function(){(T[n].q=T[n].q||[]).push(arguments)});T[n].l=+new Date();if(T.attachEvent){T.attachEvent("onload",g)}else{T.addEventListener("load",g,false)}}(window,document,"script","tpwidget","//widget.seniverse.com/widget/chameleon.js"))</script>
<script>tpwidget("init", {
"flavor": "slim",
"location": "WX4FBXXFKE4F",
"geolocation": "disabled",
"language": "zh-chs",
"unit": "c",
"theme": "chameleon",
"container": "tp-weather-widget",
"bubble": "enabled",
"alarmType": "badge",
"uid": "U508924FF9",
"hash": "278ad0b97e8ff0ba0e30d331e8b45478"
});
tpwidget("show");
</script>

step5:修改主题 themes/yilia/layout/_partial/left-col.ejs

实现效果:

image.png

百度和谷歌收录文章

具体内容:参考让Baidu和Google收录Hexo博客

yilia主题添加gitment评论

上传到github命令

hexo clean
hexo g
hexo d

赏

感谢对我的支持,让我们一起努力吧

谢谢你哦
  • Hexo

扫一扫,分享到微信

微信分享二维码
如何在网站通添加第三方插件--天气
百度地图在wordpress上的使用,wordpress添加地图插件
  1. 1. Hexo 安装
    1. 1.1. Git 安装
    2. 1.2. Node.js 安装
    3. 1.3. Hexo 安装
  2. 2. 创建项目及主题安装
    1. 2.1. 创建项目
    2. 2.2. 安装主题
      1. 2.2.1. 安装方法
      2. 2.2.2. 其他主题介绍
  3. 3. 插件选择安装
    1. 3.0.1. 更多插件介绍
  • 4. 持续优化
    1. 4.1. 设置Yilia菜单
    2. 4.2. 设置tags
    3. 4.3. 设置目录
    4. 4.4. RSS 设置
    5. 4.5. 设置展示更多
    6. 4.6. 文章排序
      1. 4.6.1. hexo-generator-index
      2. 4.6.2. Installation
      3. 4.6.3. Options
    7. 4.7. 自定义打赏功能
    8. 4.8. google 分析 GA 代码的添加
    9. 4.9. 主题中添加天气
    10. 4.10. 百度和谷歌收录文章
    11. 4.11. yilia主题添加gitment评论
    12. 4.12. 上传到github命令
  • Like Issue Page
    Error: Comments Not Initialized
    Login with GitHub
    Styling with Markdown is supported
    Powered by Gitment
    © 2017 Luck、Time
    Hexo Theme Yilia by Litten
    • 所有文章
    • 友链
    • 关于我

    tag:

    • Html
    • jquery
    • Mysql
    • PHP
    • Weather
    • GTM
    • GA
    • Hexo
    • ionic
    • 推广
    • 接口集合
    • Wordpress
    • Map
    • 插件集合
    • 日记
    • fighting
    • 自学
    • 安卓
    • 小程序
    • wepy
    • 抓包
    • 祭祀
    • 知识总结
    • 小说鉴赏
    • 太宰治
    • 梭罗
    • 美句

      缺失模块。
      1、请确保node版本大于6.2
      2、在博客根目录(注意不是yilia根目录)执行以下命令:
      npm i hexo-generator-json-content --save

      3、在根目录_config.yml里添加配置:

        jsonContent:
          meta: false
          pages: false
          posts:
            title: true
            date: true
            path: true
            text: false
            raw: false
            content: false
            slug: false
            updated: false
            comments: false
            link: false
            permalink: false
            excerpt: false
            categories: false
            tags: true
      

    • 友情链接1
    • 友情链接2
    • 友情链接3
    • 友情链接4
    • 友情链接5
    • 友情链接6