Hexo(3)-安装自己喜欢的主题

本系列其它文章:

用 GitHub + Hexo 建立你的第一个博客

[Hexo]部署博客及更新博文

欢迎在今天下面一条推送中留下你的博客地址!


本篇来讲解如何安装自己喜欢的主题!

我们之前使用 Hexo 生成的博客使用的是 Hexo 的默认主题:Landscape。怎么说呢,这个主题猛地一看还行,仔细一看还不如猛地一看,所以我决定另寻归宿。

选择主题

可以在 hexo主题总站

https://github.com/hexojs/hexo/wiki/Themes

寻找自己喜欢的主题。

我在这里推荐一个主题

yilia

https://github.com/litten/hexo-theme-yilia

也就是我正在用的主题,简洁大方,比较符合我的品位。

当然每个人的品位都不一样,你可以选择其它的主题,不过欢迎你选择 yilia 主题,这样就能继续一起愉快地折腾啦。

安装 yilia 主题

Hexo 有两份主要的配置文件(_config.yml),一份位于站点根目录下,另一份位于主题目录下。为了描述方便,在以下说明中,将前者称为 站点配置文件,后者称为 主题配置文件

下载 yilia 主题

使用 Git Shell 进入 Hexo 文件夹,输入以下两条命令:

cd Hexo git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia

启用 yilia 主题

下载完成后,打开 站点配置文件,找到 theme 字段,并将其值更改为 yilia。

验证主题是否启用

执行上面发博文的命令,刷新你的个人博客,就能看到你设置的主题是否启用。

个性化配置

我们来看看如何对默认的主题做些小修改。

首先呢,打开 hexo 文件下的主配置文件,去修改自己的名字及个人介绍。

然后修改每页要显示几篇文章以及确认你是否将主题修改为 yilia。

接下来修改主页、所有文章、以及下面图标。

下面我们再来看下这里的菜单,标签,以及友情链接和关于我的修改方法。

菜单配置要修改 主题配置文件 的 menu 内容,下面是我的主配置示例和菜单配置示例:

主配置示例

# Hexo Configuration ## Docs: https://hexo.io/docs/configuration.html ## Source: https://github.com/hexojs/hexo/ # Site title: 大懒虫 subtitle: 我想把这片田地,种满星星,带你来看~ description: 这是我的家哦~ author: 大懒虫 language:  zh-Hans timezone: # URL ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' url: http://liangwenhao.cn root: / permalink: :year/:month/:day/:title/ permalink_defaults: # Directory source_dir: source public_dir: public tag_dir: tags archive_dir: archives category_dir: categories code_dir: downloads/code i18n_dir: :lang 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: 5 pagination_dir: page # Extensions ## Plugins: https://hexo.io/plugins/ ## Themes: https://hexo.io/themes/ theme: yilia # Deployment ## Docs: https://hexo.io/docs/deployment.html deploy:  type: git  repository: https://github.com/wenhaoliang/wenhaoliang.github.io  branch: master # Extensions Plugins: - hexo-generator-feed - hexo-generator-sitemap #Feed Atom feed:  type: atom  path: atom.xml  limit: 5 #sitemap sitemap:  path: sitemap.xml # Duoshuo duoshuo_shortname: liangwenhao

菜单配置示例

# Header menu:#这里是主页菜单的内容  主页: /  所有文章: /archives # 随笔: /tags/随笔 # SubNav subnav:#在这里可以将我的网址改成你自己的  github: "https://github.com/wenhaoliang"  #weibo: "http://m.weibo.cn/u/5229251424"  rss: /404.html  zhihu: "https://www.zhihu.com/people/da-lan-chong-5"  #douban:  #mail: "641541452@qq.com"  #facebook:  #google:  twitter:  #linkedin:  #qq: 'http://wpa.qq.com/msgrd?v=3&uin=641541452&site=qq&menu=yes'  #rss: /404.html # Content excerpt_link: more fancybox: true mathjax: true # 是否开启动画效果 animate: true # 是否在新窗口打开链接 open_in_new: false # Miscellaneous google_analytics: '' favicon: /favicon.ico #你的头像url,输入你头像的图片的url地址 avatar: "https://avatars1.githubusercontent.com/u/11350373?v=3&s=460" #是否开启分享 share_jia: false share_addthis: false #是否开启多说评论,填写你在多说申请的项目名称 duoshuo: duoshuo-key #若使用disqus,请在博客config文件中填写disqus_shortname,并关闭多说评论 #关于这个多说评论框我在下篇文中讲解 duoshuo: true #是否开启云标签 tagcloud: hahaha #是否开启友情链接 #不开启—— #friends: false #开启—— friends:  Rehack: http://www.rehack.cn/  我思故我在: http://artinhuang.com/  给时光以生命: http://kingname.info/  青春样: http://www.qcyoung.com/  黄卯卯的小站: http://huangjinyuan.xyz/ #是否开启“关于我”。 #不开启—— #aboutme: false #开启—— aboutme: 懒

这样就安装主题完成了~

也可以去这个主题的作者那里学习如何个性化配置

http://litten.github.io/2014/08/31/hexo-theme-yilia/


(0)

相关推荐