搭建屬於本身的技術博客

每一個程序員都須要本身的博客

本文的博客搭建採用了靜態博客技術 。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面試題彙總》微信訂閱號。天天推送經典面試題和麪試心得技巧
===============================

微信訂閱號二維碼以下:

這裏寫圖片描述

相關文章
相關標籤/搜索