安装 hexo 主题 landscape

Landscape

NPM version

一个全新的 Hexo 默认主题。

安装

安装主题

如果您使用的是 Hexo 5.0 或更高版本,最简单的安装方式是通过 npm:

1
npm i hexo-theme-landscape

通过 git 安装:

1
git clone --depth 1 https://github.com/hexojs/hexo-theme-landscape themes/landscape

如果您想启用 RSS 功能,还需要安装 hexo-generator-feed 插件。

启用主题

修改 _config.yml 中的 theme 设置为 landscape

1
2
3
_config.yml
- theme: some-theme
+ theme: landscape

更新主题

通过 npm 安装最新版本:

1
npm install hexo-theme-landscape@latest

或者通过 git 更新到最新的 master 分支:

1
2
cd themes/landscape
git pull

配置

主题的配置文件是仓库中的 _config.yml。作为 Hexo 的默认主题,hexo-theme-landscape 在 hexo init 创建站点过程中通过 npm 安装,因此它通常位于 node_modules/hexo-theme-landscape 目录中。如果您通过 git clone 或其他方式安装,它可能位于 themes/landscape 目录中。

需要注意的是,为了防止您对主题配置文件的修改在主题升级过程中丢失或被覆盖,我们不建议直接修改这个默认配置文件。您可以将主题的 _config.yml 复制到您的博客根目录,命名为 _config.landscape.yml,并根据其中的配置选项文档进行配置(请参阅 替代主题配置)。

下面也将详细介绍一些选项的用法。

特性

FancyBox

Landscape 使用 Fancybox 来展示您的照片。您可以使用 Markdown 语法或 fancybox 标签插件来添加照片。

1
2
3
![img caption](img url)

{% fancybox img_url [img_thumbnail] [img_caption] %}

侧边栏

您可以通过编辑 sidebar 设置,将侧边栏放在站点的左侧、右侧或底部。

Landscape 提供了 5 个内置小部件:

  • category(分类)
  • tag(标签)
  • tagcloud(标签云)
  • archives(归档)
  • recent_posts(最近文章)

默认情况下,所有小部件都已启用。您可以在 widget 设置中编辑它们。

头部链接

您可以添加带有图标的链接到头部区域。

1
2
3
4
links:
github: https://github.com/your_github_account
twitter: https://twitter.com/your_twitter_account
telegram: https://t.me/your_telegram_account