hexo项目的搭建
npm install hexo-cli -g -d
hexo init
npm install
npm install hexo-deployer-git –save
hexo generat
hexo server
hexo deploy
hexo new “new article”
hexo new page “pageName” #新建页面
hexo help #查看帮助
hexo clean #清除缓存, 建议每次执行命令前先清理缓存
hexo new draft “new draft”
hexo server –drafts
hexo publish [layout]
目录结构
├── .deploy #需要部署的文件
├── node_modules #Hexo插件
├── public #生成的静态网页文件
├── scaffolds #模板
├── source #博客正文和其他源文件, 404 、favicon 、CNAME
| ├── _drafts #草稿
| └── _posts #文章
├── themes #主题
├── _config.yml #全局配置文件
└── package.json
全局站点配置文件_config.yml介绍
# Site #站点信息
title: Hexo #博客标题
subtitle: 啦啦啦 #副标题
description: 哈哈哈 #描述
author: John Doe #作者
language: zh-Hans #语言
timezone: Asia/Shanghai #时区
# URL #链接格式
url: http://yoursite.com #博客网址
root: / #根目录
permalink: :year/:month/:day/:title/ #文章的链接格式
permalink_defaults:
# Directory #目录
source_dir: source #源文件
public_dir: public #生成的文件
tag_dir: tags #标签文件夹
archive_dir: archives #归档文件夹
category_dir: categories #分类文件夹
code_dir: downloads/code #下载文件
i18n_dir: :lang #国际化
skip_render:
# Writing #写作
new_post_name: :title.md #文章标题
default_layout: post #模板
titlecase: false #标题是否换成小写
external_link: true #是否在新页面打开链接
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: true
tab_replace:
# Category & Tag #分类和标签
default_category: uncategorized
category_map:
tag_map:
# Date #时间日期格式
date_format: YYYY-MM-DD
time_format: HH:mm:ss
# Pagination #分页
per_page: 10 #每页文章数
pagination_dir: page
# Extensions #插件和主题
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: landscape
# Deployment #部署配置
## Docs: http://hexo.io/docs/deployment.html
deploy:
type:
hexo 常用配置
头像设置
avatar: /images/avatar.png
侧边栏社交链接
social:
GitHub: https://github.com/shashouzhiwang
Twitter: https://twitter.com/tongchengqiu
Zhihu: http://www.zhihu.com/people/tongchengqiu
友情链接
links_title: 友情链接
links:
Hexo: http://hexo.io/
Lmintlcx: http://blog.lmintlcx.com/
在github绑定域名
在github目录下新建CNAME(不要后缀),内容为绑定的域名,如shanshou.win
hexo 语法陷阱
配置文件的冒号后面要带空格
草稿
草稿相当于很多博客都有的“私密文章”功能。
$ hexo new draft “new draft”
会在source/_drafts目录下生成一个new-draft.md文件。但是这个文件不被显示在页面上,链接也访问不到。也就是说如果你想把某一篇文章移除显示,又不舍得删除,可以把它移动到_drafts目录之中。
如果你希望强行预览草稿,更改配置文件:
render_drafts: true
或者,如下方式启动server:
$ hexo server –drafts
下面这条命令可以把草稿变成文章,或者页面:
$ hexo publish [layout]
主题设置
下载地址
$ git clone https://github.com/iissnan/hexo-theme-next themes/next #主题的地址
更改主题设置
themes: next #主题文件夹名
主题的目录结构
├── languages #国际化
| ├── default.yml #默认
| └── zh-CN.yml #中文
├── layout #布局
| ├── _partial #局部的布局
| └── _widget #小挂件的布局
├── script #js脚本
├── source #源代码文件
| ├── css #CSS
| | ├── _base #基础CSS
| | ├── _partial #局部CSS
| | ├── fonts #字体
| | ├── images #图片
| | └── style.styl #style.css
| ├── fancybox #fancybox
| └── js #js
├── _config.yml #主题配置文件
└── README.md #主题介绍
主题配置文件_config.yml文件
menu: #菜单
home: / #首页
archives: /archives #归档
#commonweal: /404.html #404页面
#tags: /tags #标签
#categories: /categories #分类
about: /about #关于
# 小图标
favicon: /favicon.ico
# 默认关键词
keywords: "~"
# 留空使用默认的, false 禁用, 也可以写指定的地址
rss:
# Icon fonts
# default | linecons | fifty-shades | feather
icon_font: default
# 代码高亮主题 https://github.com/chriskempson/tomorrow-theme
# normal | night | night eighties | night blue | night bright
highlight_theme: normal
# MathJax Support #数学公式
mathjax: true
# Schemes #启用主题中的主题Mist
scheme: Mist
# 侧边栏
# - post 只在文章页面显示
# - always 所有页面显示
# - hide 隐藏
sidebar: always
# 自动滚动到"阅读更多"标记的下面
scroll_to_more: true
# 自动给目录添加序号
toc_list_number: true
# 自动截取摘要
auto_excerpt:
enable: false
length: 150
# Lato 字体
use_font_lato: true
# Make duoshuo show UA
# user_id must NOT be null when admin_enable is true!
# you can visit http://dev.duoshuo.com get duoshuo user id.
duoshuo_info:
ua_enable: true
admin_enable: false
user_id: 0
#admin_nickname: ROOT
## DO NOT EDIT THE FOLLOWING SETTINGS
## UNLESS YOU KNOW WHAT YOU ARE DOING
# 动画
use_motion: true
# Fancybox 看图插件
fancybox: true
# Static files
vendors: vendors
css: css
js: js
images: images
# Theme version
version: 0.4.5.1
添加网站图标
将网站图标文件 favicon.ico 放到blog/source目录下面
favicon: /favicon.ico
菜单设置
menu:
home: /
archives: /archives
categories: /categories
tags: /tags
commonweal: /404.html
about: /about
生成的页面
hexo new page “tags”
hexo new page “categories”
hexo new page “about”
网站访问量统计
找到themes/next/layout/partials/footer.wsig文件
使用 不蒜子 提供的服务
算法a: pv的方式, 单个用户连续点击n篇文章, 记录n次访问量.
<span id="busuanzi_container_site_pv">
本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
算法b: uv的方式, 单个用户连续点击n篇文章, 只记录1次访客数.
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_uv">
本站访客数<span id="busuanzi_value_site_uv"></span>人次
</span>
网站运行时间
<script>
var birthDay = new Date("11/20/2014");
var now = new Date();
var duration = now.getTime() - birthDay.getTime();
var total= Math.floor(duration / (1000 * 60 * 60 * 24));
document.getElementById("showDays").innerHTML = "本站已运行 "+total+" 天";
</script>
<span id="showDays"></span>