Hexo(+NexT)工具工具使用指南

Hexo-Next-主题优化(一)

2017-09-11  本文已影响1393人  Devin_

1. 常用命令

2.更换主题,以Next主题为例

$ cd your-hexo-site
$ git clone https://github.com/iissnan/hexo-theme-next themes/next
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next

3.站点初始设置

# Site
title: Hexo #网站标题
subtitle: #网站副标题
description: #网站描述
author: author #您的名字
language: zh-Hans #网站使用的语言
timezone: Asia/Shanghai #网站时区。Hexo 默认使用您电脑的时区。

4.设置主题风格

# ---------------------------------------------------------------
# Scheme Settings
# ---------------------------------------------------------------

# Schemes
#scheme: Muse # 默认 Scheme,这是 NexT 最初的版本,黑白主调,大量留白
#scheme: Mist # Muse 的紧凑版本,整洁有序的单栏外观
scheme: Pisces # 双栏 Scheme,小家碧玉似的清新
#scheme: Gemini # 类似 Pisces

5.设置菜单项的显示文本和图标

menu.png
5.1设置菜单项的显示文本
menu:
  home: 首页
  archives: 归档
  categories: 分类
  tags: 标签
  about: 关于
  search: 搜索
  schedule: 日程表
  sitemap: 站点地图
  commonweal: 公益404
  # 新增menu
  catalogue: 目录
5.2设定菜单项的图标
# Enable/Disable menu icons.
# Icon Mapping:
#   Map a menu item to a specific FontAwesome icon name.
#   Key is the name of menu item and value is the name of FontAwesome icon. Key is case-senstive.
#   When an question mask icon presenting up means that the item has no mapping icon.
menu_icons:
  enable: true
  #KeyMapsToMenuItemKey: NameOfTheIconFromFontAwesome
  home: home
  about: user
  categories: th
  schedule: calendar
  tags: tags
  archives: archive
  sitemap: sitemap
  commonweal: heartbeat
  #新增menu_icon
  catalogue: th-list
5.3设置菜单项对应的文件目录
# ---------------------------------------------------------------
# Menu Settings
# ---------------------------------------------------------------

# When running the site in a subdirectory (e.g. domain.tld/blog), remove the leading slash (/archives -> archives)
menu:
  home: /
  categories: /categories/
  #about: /about/
  archives: /archives/
  #tags: /tags/
  #sitemap: /sitemap.xml
  #commonweal: /404/
  #新增menu
  catalogue: /catalogues/
5.4创建菜单项对应文件目录,以分类为例
$ cd your-hexo-site
$ hexo new page categories
5.5编辑刚新建的页面,设置分类
title: 分类
date: 2014-12-22 12:39:04
categories: Testing #分类名
type: "categories"
---

6.头像设置

logoBorderRadius.png
6.1添加头像
# Sidebar Avatar
# in theme directory(source/images): /images/avatar.jpg
# in site  directory(source/uploads): /uploads/avatar.jpg
avatar: http://example.com/avatar.png
avatar: /images/blogLogo.png
6.2设置头像边框为圆形框
.site-author-image {
  display: block;
  margin: 0 auto;
  padding: $site-author-image-padding;
  max-width: $site-author-image-width;
  height: $site-author-image-height;
  border: $site-author-image-border-width solid $site-author-image-border-color;
 // 修改头像边框
  border-radius: 50%;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
}
6.3特效:鼠标放置头像上旋转
logoTransition.gif
.site-author-image {
  display: block;
  margin: 0 auto;
  padding: $site-author-image-padding;
  max-width: $site-author-image-width;
  height: $site-author-image-height;
  border: $site-author-image-border-width solid $site-author-image-border-color;
 // 修改头像边框
  border-radius: 50%;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  // 设置旋转
  transition: 1.4s all;
}
// 可旋转的圆形头像,`hover`动作
.site-author-image:hover {
    -webkit-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -ms-transform: rotate(360deg);
    -transform: rotate(360deg);
}

7.浏览页面的时候显示当前浏览进度

scrollpercent.png
  # Scroll percent label in b2t button
  scrollpercent: true
 # Back to top in sidebar
  b2t: true

  # Scroll percent label in b2t button
  scrollpercent: true

效果如下图:

b2t.png

8.文章创建和删除

$ cd you-site
$ hexo new post "you title"
$ hexo clean
在/source/_posts/中直接删除了相应的.md文件
$ hexo g 

9.标签设置

tags.png
9.1创建标签目录
$ cd you-site
$ hexo new page tags
---
title:  #页面主题
date: 2017-08-18 15:00:55 #当前创建文件时间
type: "tags" # 设置页面类型
---
9.2设置标签云
---
layout: layout
title: 标签1
date: 2017-08-18 15:41:18
tags: 标签1 #此文章在`标签1 `标签下
#tags: [标签1,标签2] #此文章在`标签1,标签2`下
---

10侧边栏设置

10.1 设置侧边栏社交链接
# Social links
social:
  GitHub: https://github.com/your-user-name
  Twitter: https://twitter.com/your-user-name
  Weibo: https://weibo.com/your-user-name
  douban: https://douban.com/people/your-user-name
  zhihu: https://www.zhihu.com/people/your-user-name
  # 等等
10.2 设置侧边栏社交图标
social_icons:
  enable: true
  # Icon Mappings.
  # KeyMapsToSocalItemKey: NameOfTheIconFromFontAwesome
  GitHub: github
  Twitter: twitter
  Weibo: weibo
  Linkedin: linkedin
10.3RSS
Rss.png
$ npm install hexo-generator-feed --save
# feed
# Dependencies: https://github.com/hexojs/hexo-generator-feed
feed:
  type: atom
  path: atom.xml
  limit: 20
  hub:
  content:
10.4友情链接
# Blog rolls
links_title: 友情链接 #标题
links_layout: block #布局,一行一个连接
#links_layout: inline
links: #连接
  baidu: http://example.com/
  google: http://example.com/

Hexo-Next-主题优化(二)
Hexo-Next-主题优化(三)
Hexo-Next-主题优化(四)

上一篇 下一篇

猜你喜欢

热点阅读