Hexo主题casper使用教程

demo

casper

安装

下载

git clone https://github.com/xzhih/hexo-theme-casper.git themes/hexo-casper

更改主题为casper

Hexo根目录的配置文件_config.yml中的theme改为hexo-casper

升级

建议先备份以下再执行下面的操作。

cd themes/casper 
git pull

添加统一的文章模板参数

把下面的内容添加到Hexo根目录下的scaffolds/post.md

cover_img:     # 在文章摘要上显示
feature_img:   # 在文章详细页面上置顶
description:   # 文章描述
keywords:      # 关键字

自定义配置

编辑themes/hexo-casper/_config.yml进行配置。

# Config
rss:            # link
favicon: https://i.loli.net/2017/11/26/5a19c0b50432e.png
blog_logo: 
header_image: https://i.loli.net/2017/11/26/5a19c56faa29f.jpg
bio: This is a demo
post_toc: true

# 菜单
menu:
  About: /about
  Archives: /archives
  # 其他的可以按照上面的模板添加

# 作者
author_image:   # 链接
author_bio:     # 描述
author_location: # 地址

# 社交链接
social:
  facebook: https://www.facebook.com
  twitter: https://www.twitter.com
  twitter: https://twitter.com
  facebook: https://facebook
  telegram:
  bilibili:
  youtube:

# 插件(显示在网站底部)
widgets:
  recent_posts: true
  category: true
  tagcloud: true
  # 这是个简洁的主题,我认为3个就够了

# 文章图片相册(点击图片可以放大)
# https://github.com/sachinchoolur/lightgallery.js
lightgallery: true

# 懒加载
# 首页已经默认开启,其他页面在此开启
# https://github.com/dinbror/blazy
lazyload: true

# 搜索功能
local_search: true

# Valine 评论系统
# https://valine.js.org
comment: false
valine:
  notify: false # mail notifier , https://github.com/xCss/Valine/wiki 
  verify: false # Verification code
  appId: # your leancloud application appid
  appKey: # your leancloud application appkey
  placeholder: Just go go # comment box placeholder
  avatar: mm # gravatar style
  pageSize: 10 # pagination size

# PWA 
# 你需要在 hexo 目录的 source 文件夹里创建一个 manifest.json 文件
manifest: false
service_workers: false

navColor: '3c484e'

# Baidu 链接提交
baidu: false

# Google Analytics
googleAnalytics: false
GA_TRACKING_ID: UA-XXXXXXXXXX-1

本地搜索功能

安装

npm install hexo-generator-search --save

配置

Hexo根目录下中的_config.yml进行配置。

search:
   path:search.xml 
   field:post 
   content:true

path-文件路径。默认为search.xml。如果文件扩展名为.json,则输出格式为JSON。否则将导出XML格式文件。
filed-要搜索的文件范围。

  • post(默认)-所有帖子
  • page -所有页面
  • all -所有帖子和页面

content-是否包含每篇文章的全部内容。默认为true。如果false,生成的结果仅覆盖没有主体的标题和其他元信息。

排除索引

要将某个帖子或页面排除在索引之外,您只需indexing: false在其前端的顶部插入设置,例如:

title: "Code Highlight"
date: "2014-03-15 20:17:16"
tags: highlight
categories: Demo
description: "A collection of Hello World applications from helloworld.org."
toc: true
indexing: false
---