搭建属于本身的技术博客

每一个程序员都须要本身的博客

本文的博客搭建采用了静态博客技术 。html

技术框架是:github pages和hexo

hexo安装

hexo介绍

Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其余渲染引擎)解析文章,在几秒内,便可利用靓丽的主题生成静态网页。node

安装hexo以前须要先安装git和node.js

参考网站:https://hexo.io/zh-cn/docs/index.htmlgit

安装git:

sudo yum install git-core程序员

安装node.js

Wget:github

$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
安装完成后,重启终端并执行下列命令便可安装 Node.js。面试

$ nvm install stable
安装 Hexo
全部必备的应用程序安装完成后,便可使用 npm 安装 Hexo。npm

$ npm install -g hexo-clibash

github pages的配置

1.新建repo微信

2.设置名字为username.github.iohexo

3.点击setting,选择launch automatic page generater,而后点击continue to layouts,开通pages

配置hexo

1.初始化

hexo init folder
cd folder
npm install

2.配置文件

_config文件里面包含了配置信息
基本的配置信息介绍

网站

参数 描述
title 网站标题
subtitle 网站副标题
description 网站描述
author 您的名字
language 网站使用的语言
timezone 网站时区。Hexo 默认使用您电脑的时区。时区列表。好比说:America/New_York, Japan, 和 UTC 。

网址

参数 描述 默认值
url 网址
root 网站根目录
permalink 文章的 永久连接 格式 :year/:month/:day/:title/
permalink_default 永久连接中各部分的默认值
网站存放在子目录
若是您的网站存放在子目录中,例如 http://yoursite.com/blog,则请将您的 url 设为 http://yoursite.com/blog 并把 root 设为 /blog/。

目录

参数 描述 默认值
source_dir 资源文件夹,这个文件夹用来存放内容。 source
public_dir 公共文件夹,这个文件夹用于存放生成的站点文件。 public
tag_dir 标签文件夹 tags
archive_dir 归档文件夹 archives
category_dir 分类文件夹 categories
code_dir Include code 文件夹 downloads/code
i18n_dir 国际化(i18n)文件夹 :lang
skip_render 跳过指定文件的渲染,您可以使用 glob 表达式来匹配路径。

3..本地测试

hexo g # 或者hexo generate
hexo s # 或者hexo server,能够在http://localhost:4000/ 查看

hexo部署到github

1.安装扩展工具

npm install hexo-deployer-git --save

2.clone项目到本地

cd
$ git clone clone地址连接

3.建立一个deploy脚本文件

fengsehng.github.io是个人项目名字

#!/bin/bash
# This is our first script.
hexo generate
cp -R public/* fengsehng.github.io
cd fengsehng.github.io
git add .
git commit -m “update”
git push origin master

4.大公告成,查看github pages网址:https://fengsehng.github.io/

这里写图片描述
hexo技巧:
=======

在工程目录下添加插件
添加sitemap和feed插件

npm install hexo-generator-feed
npm install hexo-generator-sitemap
修改_config.yml,增长如下内容

# Extensions
Plugins:
- hexo-generator-feed
- hexo-generator-sitemap
#Feed Atom
feed:
  type: atom
  path: atom.xml
  limit: 20
#sitemap
sitemap:
  path: sitemap.xml

另外还有其余几个经常使用命令:

hexo new "postName" 新建文章
hexo new page "pageName" 新建页面
参考:
http://jiji262.github.io/2016/04/15/2016-04-15-hexo-github-pages-blog/
http://www.jianshu.com/p/05289a4bc8b2
https://hexo.io/zh-cn/docs/configuration.html

个人微信二维码以下,欢迎交流讨论

这里写图片描述
欢迎关注《IT面试题汇总》微信订阅号。天天推送经典面试题和面试心得技巧
===============================

微信订阅号二维码以下:

这里写图片描述

相关文章
相关标签/搜索