手把手教从零开始在GitHub上使用Hexo搭建博客教程(二)-Hexo参数设置

来源:互联网 发布:装修公司半包猫腻知乎 编辑:程序博客网 时间:2024/04/30 05:42

手把手教GitHub+Hexo博客搭建教程(二)

前言

前文手把手教从零开始在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 #资源文件夹,默认是sourcepublic_dir: public #公共文件夹,默认是publictag_dir: tags #标签文件夹,默认是tagsarchive_dir: archives #档案文件夹,默认是archivescategory_dir: categories #分类文件夹,默认是categoriescode_dir: downloads/code #代码文件夹,默认是downloads/codei18n_dir: :lang #国际化文件夹,默认跟language相同skip_render: [] #不需要渲染的文件夹或文件夹,放在[]中# Writing 文章写作选项new_post_name: :title.md # File name of new postsdefault_layout: post #默认布局模板titlecase: false # Transform title into titlecaseexternal_link: true # Open external links in new tabfilename_case: 0render_drafts: falsepost_asset_folder: falserelative_link: falsefuture: truehighlight: #高亮显示  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 paginationper_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.htmldeploy:  type: git  repo: 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,表示依赖项。

  • RSS订阅插件
    hexo-generator-feed:生成rss订阅文件

    npm install hexo-generator-feed --save

    添加配置信息

    #sitemapsitemap:  path: sitemap.xml
  • SiteMap插件
    hexo-generator-sitemap:生成易于搜索引擎搜素的网站地图

    npm install hexo-generator-sitemap --save

    添加配置信息:

    #feedatom:  type: atom  path: atom.xml  limit: 20

可以在主题配置文件中添加相关配置,可以在页面上显示。
比如,添加链接信息

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修改的。

切换主题

  1. 将找到的主题源码下载到themes文件夹中;
    比如,jacman主题在github上,通过克隆到themes中:

    git clone https://github.com/wuchong/jacman themes/jacman
  2. 在配置**_config.yml**文件中修改主题配置,比如修改theme: landscapetheme: jacman
  3. 修改主题配置文件**_config.yml**,此配置文件在主题文件夹下面。
    相关的配置信息可根据主题文档进行配置。

原文:手把手教从零开始在GitHub上使用Hexo搭建博客教程(二)-Hexo参数设置

0 0
原创粉丝点击