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

前言

前文手把手教从零开始在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,表示依赖项。

  1. RSS订阅插件
    hexo-generator-feed:生成rss订阅文件
npm install hexo-generator-feed --save

添加配置信息

# sitemapsitemap:  path: sitemap.xml
  1. 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
  1. Git插件
    hexo-deployer-git:使用git同步代码到git仓库中
npm install hexo-deployer-git --save
  1. 内置插件

在Hexo 3.0中以下插件是内置的:

  1. hexo-generator-archive

  2. hexo-generator-category

  3. hexo-generator-index

  4. hexo-generator-tag

  5. hexo-renderer-ejs

  6. hexo-renderer-marked

  7. hexo-renderer-stylus

  8. hexo-server

更多插件可以查阅官方插件页

主题

默认的主题是landscape

如果不喜欢,可以在网上找到自己喜欢的主题,作为自己的主题使用。
官方主题地址:传送门

比如我目前使用的是基于jacman修改的。

切换主题

  1. 将找到的主题源码下载到themes文件夹中;
    比如,jacman主题在github上,通过克隆到themes中:
git clone https://github.com/wuchong/jacman themes/jacman
  1. 在配置_config.yml文件中修改主题配置,比如修改theme: landscape为theme: jacman;

  2. 修改主题配置文件_config.yml,此配置文件在主题文件夹下面。
    相关的配置信息可根据主题文档进行配置。

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

关键字:Hexo, 插件, 文件, Github


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部