hexo+css建立本身的blog(搭建)

1、什麼是hexo

Hexo是一個快速、簡潔且高效的博客框架,使用Markdown(或其餘渲染引擎)解析文章,在幾秒內,便可利用靚麗的主題生成靜態網頁。目前比較火的vue和weex的文檔都是使用hexo框架實現的。css

2、hexo的安裝

安裝hexo前,確保電腦中已經安裝了node和git。html

node安裝

方法1、
    直接安裝node:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
方法2、
    先安裝homebrew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    後安裝node:brew install node

git安裝

先安裝homebrew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
後安裝git:brew install git

hexo安裝

npm install -g hexo-cli

3、建立項目

  1. 新建項目: hexo init foldervue

  2. 進入: cd folder>node

  3. 安裝依賴包: npm installgit

  4. 新建一篇文章: hexo new iOS-APIs (文件會在/source/_posts下)github

  5. 啓動: hexo servernpm

  6. 瀏覽器打開: http://localhost:4000/document/瀏覽器

4、hexo配置

配置文件爲_config.yml
參考: https://hexo.io/docs/configur...
github: https://github.com/hexojs/hexo/ruby

Site (網站)

  1. 網站標題
    title: weex使用手冊weex

  2. 網站副標題
    subtitle: weex中文手冊

  3. 網站描述
    description: 整理weex手冊, 包括通用特性, 內建組件, 內建模塊, CSS 單位, 通用事件, Native DOM APIs, Weex 實例變量, Web 標準, JS Service, Vue, 高階知識, 遷移

  4. 做者名字
    author: lu.wei

  5. 網站使用的語言
    language: 簡體中文

  6. 網站時區Hexo 默認使用您電腦的時區。時區列表。好比說:America/New_York, Japan, 和 UTC 。
    timezone: UTC

URL (網址)

若是您的網站存放在子目錄中,例如 http://yoursite.com/blog,則請將您的 url 設爲 http://yoursite.com/blog 並把 root 設爲 /blog/。

  1. 網址
    url: https://github.com/stardew516...

  2. 網站根目錄
    root: /document/

  3. 文章的 永久連接 格式
    permalink: :year/:month/:day/:title/

  4. 永久連接中各部分的默認值
    permalink_defaults:

Directory (目錄)

  1. 資源文件夾,這個文件夾用來存放內容。
    source_dir: source

  2. 公共文件夾,這個文件夾用於存放生成的站點文件。
    public_dir: public

  3. 標籤文件夾
    tag_dir: tags

  4. 歸檔文件夾
    archive_dir: archives

  5. 分類文件夾
    category_dir: categories

  6. Include code 文件夾
    code_dir: downloads/code

  7. 國際化(i18n)文件夾
    i18n_dir: :lang

  8. 跳過指定文件的渲染,您可以使用 glob 表達式來匹配路徑。
    skip_render:

Writing (文章)

  1. 新建文章的文件名稱
    new_post_name: :title.md

  2. 預設佈局
    default_layout: post

  3. 在中文和英文之間加入空格
    auto_spacing: false

  4. 把標題轉換爲 title case
    titlecase: false

  5. 在新標籤中打開連接
    external_link: true

  6. 把文件名稱轉換爲 (1) 小寫或 (2) 大寫
    filename_case: 0

  7. 顯示草稿
    render_drafts: false

  8. 啓動 Asset 文件夾
    post_asset_folder: true

  9. 把連接改成與根目錄的相對位址
    relative_link: false

  10. 顯示將來的文章
    future: true

  11. 代碼塊的設置

    highlight:
      enable: true
      line_number: true
      auto_detect: true
      tab_replace:

Home page setting (主頁設置)

1. path: 博客索引頁的跟路徑,默認爲空
2. per_page: 每頁展現的文章量, 爲0時表示不分頁
3. order_by: 排序, 默認日期降序
index_generator:
  path: ''
  per_page: 10
  order_by: -date

Category & Tag (分類 & 標籤)

  1. 默認分類
    default_category: uncategorized

  2. 分類別名
    category_map:

  3. 標籤別名
    tag_map:

Date / Time format (日期 / 時間格式)

hexo使用Moment.js來解析和顯示時間。
能夠參照http://momentjs.com/docs/#/di...來自定義日期格式。

  1. 日期格式
    date_format: YYYY-MM-DD

  2. 時間格式
    time_format: HH:mm:ss

Pagination (分頁)

  1. 每頁顯示的文章量 (0 = 關閉分頁功能)
    per_page: 10

  2. 分頁目錄
    pagination_dir: page

Extensions (擴展)

插件: https://hexo.io/plugins/
主題: https://hexo.io/themes/

  1. 當前主題名稱。值爲false時禁用主題
    theme: landscape

Deployment (部署)

參考: https://hexo.io/docs/deployme...

  1. 部署部分的配置

    deploy:
      type: git
      repo: https://github.com/stardew516/document
      branch: master
      message: hexo + css

5、部署

github上部署:

  1. 安裝hexo-deployer-git: npm install hexo-deployer-git --save

  2. _config.yml 中配置

    # 部署部分的設置
    deploy:
      type: git
      repo: https://github.com/stardew516/document
      branch: master
      message: hexo + css
  3. 終端進入目錄,運行: hexo deploy

相關文章
相關標籤/搜索