前言
前文手把手教從零開始在GitHub上使用Hexo搭建博客教程(一)-附GitHub注冊及配置介紹了github注冊、git相關設置以及hexo基本操作。
本文主要介紹一下hexo的常用參數設置。
配置文件說明
網站配置文件是在根目錄下的_config.yml文件,是yaml格式的。
所有的配置項后面的冒號(:)與值之間要有一個空格。
官方配置文件說明
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/# Site 網站信息
title: 網站標題
subtitle: 網站副標題
description: 網站描述
author: 網站作者名字
language: #網站語言,默認是英語(en)
timezone: #網站時區# URL 網站設置
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: seayxu.github.io #網站的地址
root: / #網站的根目錄,如果是子文件夾下,則填寫子文件夾路徑
permalink: :year/:month/:day/:title/ #文章鏈接地址格式
permalink_defaults: # Directory 目錄設置
source_dir: source #資源文件夾,默認是source
public_dir: public #公共文件夾,默認是public
tag_dir: tags #標簽文件夾,默認是tags
archive_dir: archives #檔案文件夾,默認是archives
category_dir: categories #分類文件夾,默認是categories
code_dir: downloads/code #代碼文件夾,默認是downloads/code
i18n_dir: :lang #國際化文件夾,默認跟language相同
skip_render: [] #不需要渲染的文件夾或文件夾,放在[]中# Writing 文章寫作選項
new_post_name: :title.md # File name of new posts
default_layout: post #默認布局模板
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight: #高亮顯示enable: true #默認開啟line_number: true #顯示行號,默認開啟auto_detect: falsetab_replace:# Category & Tag 分類和標簽
default_category: uncategorized #默認分類名稱
category_map:
tag_map:# Date / Time format #日期/時間格式
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD #日期格式
time_format: HH:mm:ss #時間格式# Pagination #分頁信息
## Set per_page to 0 to disable pagination
per_page: 10 #每頁顯示數量,設置為0表示不啟用分頁
pagination_dir: page #分頁文件夾名稱# Extensions 擴展
## Plugins: https://hexo.io/plugins/ #插件
plugins:hexo-generator-feed #RSS訂閱插件hexo-generator-sitemap #sitemap插件## Themes: https://hexo.io/themes/ #主題
theme: landscape #主體名稱# Deployment 部署
## Docs: https://hexo.io/docs/deployment.html
deploy:type: gitrepo: git@github.com:SeayXu/seayxu.github.io.git #github倉庫地址branch: master # github分支
常用插件
如果是擴展插件,要在_config.yml配置文件中添加插件信息,是plugins配置項。
比如下面的兩個插件:
plugins:hexo-generator-feed #RSS訂閱插件hexo-generator-sitemap #sitemap插件
然后,安裝插件,后面要加上--save,表示依賴項。
npm install hexo-generator-feed --save
添加配置信息
#sitemap
sitemap:path: sitemap.xml
npm install hexo-generator-sitemap --save
添加配置信息:
#feed
atom:type: atompath: atom.xmllimit: 20
可以在主題配置文件中添加相關配置,可以在頁面上顯示。
比如,添加鏈接信息
links:Feed: /atom.xmlSiteMap: /sitemap.xml
npm install hexo-deployer-git --save
在Hexo 3.0中以下插件是內置的:
hexo-generator-archive
hexo-generator-category
hexo-generator-index
hexo-generator-tag
hexo-renderer-ejs
hexo-renderer-marked
hexo-renderer-stylus
hexo-server
更多插件可以查閱官方插件頁
主題
默認的主題是landscape
如果不喜歡,可以在網上找到自己喜歡的主題,作為自己的主題使用。
官方主題地址:傳送門
比如我目前使用的是基于jacman修改的。
切換主題
將找到的主題源碼下載到themes文件夾中;
比如,jacman主題在github上,通過克隆到themes中:
git clone https://github.com/wuchong/jacman themes/jacman
在配置_config.yml文件中修改主題配置,比如修改theme: landscape為theme: jacman;
修改主題配置文件_config.yml,此配置文件在主題文件夾下面。
相關的配置信息可根據主題文檔進行配置。
【Hexo博客交流群】
群號:582271078
原文:手把手教從零開始在GitHub上使用Hexo搭建博客教程(二)-Hexo參數設置
總結
以上是生活随笔為你收集整理的手把手教从零开始在GitHub上使用Hexo搭建博客教程(二)-Hexo参数设置的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。