设为首页 加入收藏

TOP

使用Hexo开源博客系统,轻松搭建你的个人博客(2)- 配置篇(一)
2019-09-30 16:49:19 】 浏览:64
Tags:使用 Hexo 开源 博客 系统 轻松 搭建 个人 配置

上一章节,我们介绍了Hexo的基础搭建,搭建完大家一定发现,是英文版本的,并且页面有点丑陋。这一章节,就来跟大家介绍Hexo的配置和主题的设置。

站点信息

上一章有跟大家提到过_config.yml这个文件,这个我们先称之为站点全局的配置文件,后续我们说到主题的时候,也会有一个这样的文件,暂时称它主题配置文件。
我们先来看一下全局配置文件主要有哪些内容:

# Site 站点主配置
title: Hexo  # 网站标题
subtitle:    # 网站副标题
description:   # 网站描述
keywords:      # 可以不填写保持默认
author: John Doe  # 网站拥有者昵称
language:    # 网站语言设置,一般根据依赖的主题而定
timezone:    # 网站时区设置,一般不填写保持默认

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url:   # 网站url设置
root:  # 网站根目录链接
permalink: :year/:month/:title.html  # 文章链接,默认是按照 /年/月/日/文章标题 设置的链接
permalink_defaults:  # 默认链接形式
......
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme:  #主题

这些可根据需要设置,其余默认即可,git配置和站点地图配置后续用到再介绍。
信息配置完记得执行hexo g && hexo s,刷新浏览器查看效果。

安装Next主题

主题大家可以在官网下载(https://hexo.io/themes)也可以到GitHub搜索,我推荐使用Next主题,该主题几乎占领了Hexo博客的半壁江山。
Next主题下载地址:https://github.com/theme-next/hexo-theme-next.git
这边介绍的版本是Next6,在Next6版本上其实增加了很多Next5需要手动配置的东西,并且Next5已经停止维护了,所以建议使用Next6版本。

下载Next主题

两种方式:
1.使用git clone命令将Next仓库克隆到hexo目录下的themes/next,需要在根目录下执行,命令为:git clone https://github.com/theme-next/hexo-theme-next.git themes/next
2.直接在Github页面上选择绿色的按钮Clone or Download下载压缩包,然后解压到themes目录下,名字可自行修改。

设置为Next主题

打开全局配置文件_config.yml,找到theme,设置如下:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: hexo-theme-next   #此处填入你在themes目录下的next主题目录名

测试Next主题

在Git Bash中执行如下命令:

hexo clean && hexo g && hexo s

命令执行完成后在浏览器中输入http://localhost:4000即可查看安装好的Next主题。

配置Next主题

在主题目录下面,也有一个_config.yml的配置文件,我们就叫它主题配置文件,下面我们开始配置。

网站图标设置

打开_config.yml,找到favicon的位置,如下所示:

favicon:
  small: /images/favicon-16x16-next.png
  medium: /images/favicon-32x32-next.png
  apple_touch_icon: /images/apple-touch-icon-next.png
  safari_pinned_tab: /images/logo.svg
  #android_manifest: /images/manifest.json
  #ms_browserconfig: /images/browserconfig.xml

将图片放到你的next主题下面的source/images目录下面,然后在主题配置文件中设置即可。

关闭底部由hexo强力驱动

在footer中,将powered和theme下的属性全部设置为false

footer:
  ...
  powered:
    # Hexo link (Powered by Hexo).
    enable: false
    # Version info of Hexo after Hexo link (vX.X.X).
    version: false

  theme:
    # Theme & scheme info link (Theme - NexT.scheme).
    enable: false
    # Version info of NexT after scheme info (vX.X.X).
    version: false

菜单栏设置

menu:
  home: / || home
  #about: /about/ || user
  tags: /tags/ || tags
  categories: /categories/ || th
  archives: /archives/ || archive
  #schedule: /schedule/ || calendar
  #sitemap: /sitemap.xml || sitemap
  #commonweal: /404/ || heartbeat

# Enable / Disable menu icons / item badges.
menu_settings:
  enable: true  #表示是否显示菜单图标icons
  badges: false  # 显示每个菜单下面有多少个内容

||后面是fontawesome中的图标名称,如果想要修改图标,可以去FontAwesome官网找自己喜欢的图标样式。

主题风格设置

# Schemes
#scheme: Muse
#scheme: Mist
#scheme: Pisces
scheme: Gemini

默认是Muse,我是使用Gemini,大家可以每个都试看看,看喜欢哪个。

社交链接设置

social:
  GitHub: https://github.com/codernice || github
  #E-Mail: mailto:yourname@gmail.com || envelope
  #Weibo: https://weibo.com/yourname || weibo
  #Google: https://plus.google.com/yourname || google
  #Twitter: https://twitter.com/yourname || twitter
  #FB Page: https://www.facebook.com/yourname || facebook
  #VK Group: https://vk.com/yourname || vk
  #StackOverflow: https://stackoverflow.com/your
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇vue实现简易计算器 下一篇jQuery中$()可以有两个参数

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目