hexo 是一个基于Node.js的静态博客程序,能够方便的生成静态网页托管在github上.Hexo简单优雅, 并且风格多变, 适合搭建我的博客,并且支持多平台的搭建.
平台
Ubuntu14.04php
使用nvm安装node.js:
cURL:html
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
Wget:node
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
安装完后,用nvm安装node.js.git
nvm install 4
npm install -g hexo-cli
$mkdir ~/blog
$hexo init ~/blog #初始化博客
$cd ~/blog
$hexo generate #生成博客
$hexo server #运行本地服务
在浏览器输入http://localhost:4000就能够看到效果.github
配置完后,就能够写markdown文章了,进入博客目录,shell
$hexo new "postname" #文章名字是postname
博文会自动生成在博客目录下source/_posts/postName.mdnpm
#文件自动生成格式:
title: "It Starts with iGaze: Visual Attention Driven Networkingwith Smart Glasses" #博文题目
date: 2014-11-21 11:25:38 #生成时间
tags: Paper #标签, 多个标签使用格式[Paper1, Paper2, Paper3,...]
---
若是不想博文在首页所有显示, 并能出现阅读全文按钮效果, 须要在你想在首页显示的部分下添加 浏览器
1.检查是否已安装ssh,若是没有则安装
2.检查是否存在ssh公钥.ruby
$cd ~/.ssh
3.生成ssh公钥bash
$ ssh-keygen -t rsa -C "your_email@youremail.com"
生成了~/.ssh目录.
输入github密码
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Your identification has been saved in /home/you/.ssh/id_rsa.
# Your public key has been saved in /home/you/.ssh/id_rsa.pub.
# The key fingerprint is: ...
4.将公钥添加到github
打开github,找到帐户里面添加SSH,把~/.ssh/idrsa.pub的内容复制到key里面。
5.测试是否生效
使用下面的命令测试
$ssh -T git@github.com
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
输入yes
Hi username!
You've successfully authenticated, but GitHub does not provide shell access.
成功.
1.安装部署到git的插件:
npm install hexo-deployer-git --save
2.修改~/blog/_config.yml文件:
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: git
repository: git@github.com:goodluckcwl/goodluckcwl.github.io.git
branch: master #部署分支,通常使用master主分支
执行:
$hexo deploy
打开你的github我的博客.
在hexo官网下载主题,修改~/blog/_config.yml文件.
数学公式显示使用Mathjax引擎,能够下载插件hexo-math.
Markdown 里使用 Mathjax 有一个很大的缺点,会把两个_按照Markdown的语法解释.
该冲突主要是因为对 \ 和 _ 的转义形成的。找到 marked.js脚本文件, 一般在:/blog/node_modules/hexo-renderer-marked/node_modules/marked/lib/markd.js,先复制一份保存,再修改:
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
改成
escape: /^\\([`*\[\]()#+\-.!_>])/,
再将
return '<em>' + text + '</em>';
改成:
return '_' + text + '_';
取消markdown转义,这样数学公式就显示正确了.
haroopad