前文手把手教从零开始在GitHub上使用Hexo搭建博客教程(一)-附GitHub注册及配置介绍了github注册、git相关设置以及hexo基本操做。html
本文主要介绍一下hexo的经常使用参数设置。git
网站配置文件是在根目录下的_config.yml文件,是yaml格式的。
全部的配置项后面的冒号(:)与值之间要有一个空格。
官方配置文件说明github
# 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: false tab_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: git repo: git@github.com:SeayXu/seayxu.github.io.git #github仓库地址 branch: master # github分支
若是是扩展插件,要在_config.yml配置文件中添加插件信息,是plugins配置项。
好比下面的两个插件:npm
plugins: hexo-generator-feed #RSS订阅插件 hexo-generator-sitemap #sitemap插件
而后,安装插件,后面要加上--save
,表示依赖项。hexo
RSS订阅插件
hexo-generator-feed:生成rss订阅文件布局
npm install hexo-generator-feed --save
添加配置信息post
#sitemap sitemap: path: sitemap.xml
SiteMap插件
hexo-generator-sitemap:生成易于搜索引擎搜素的网站地图网站
npm install hexo-generator-sitemap --save
添加配置信息:搜索引擎
#feed atom: type: atom path: atom.xml limit: 20
能够在主题配置文件中添加相关配置,能够在页面上显示。
好比,添加连接信息atom
links: Feed: /atom.xml SiteMap: /sitemap.xml
Git插件
hexo-deployer-git:使用git同步代码到git仓库中
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