Skip to content
Published at:

本站搭建相关文档及设置

写这篇文章是为了自己在修改本站时,方便查找相关文档

本站基于:Hexo(NexT 主题) + Github Pages

相关文档

Hexo

官网:https://hexo.io/

相关常用命令:

shell
$ hexo version                                # version
$ hexo help                                   # help信息
$ hexo help [command]                         # 子命令help信息
$ hexo init [folder]                          # 新建网站
$ hexo new [layout] <title>                   # 新建页面 layout:post(Default)/page/draft
$ hexo new page --path about/me "About me"    # Customize the path of the post
$ hexo publish [layout] <filename>            # publish draft
$ hexo render <filename>                      # 把md文件渲染成html文件
$ hexo list <type>                            # 显示网站相关信息types: page, post, route, tag, category

$ hexo server/s                               # 本地运行
$ hexo generate/g                             # 生成网站
$ hexo deploy/d                               # 部署
$ hexo clean                                  # 清理生成的网站和cache

NexT 主题

官网:https://theme-next.js.org/

选这个主题是因为简洁,所以在配置的时候把一些花里胡哨的都给屏蔽了

安装:

shell
$ npm install hexo-theme-next

更新主题:

shell
$ npm update hexo-theme-next

主页修改为文章归档:

默认主页是文章标题 + 文章部分内容 的列表,next主题的官网https://theme-next.js.org/pisces/ 就是这样;我的想法是:当用户一进入到主页应该显示尽可能多的(文章标题)重要信息概要信息,其次才是(文章内容)信息的内容,所以把默认的主页换成了文章归档页(文章标题列表)。

yaml
# _config.yml文件:
archive_dir: / # 改成/

index_generator:
  path: archives # 改成archives

本地搜索

默认不能本地搜索,不能搜索Custom Pages的内容,开启:

yaml
# _config.yml文件:
search:
  path: search.xml
  field: all # post改成all
  content: true
  format: html

文章排版调整

  • 文章字体、表格和代码字体
  • 文章行高、代码行高

source/_data/variables.styl

bash
// Font size of articles.
$font-size-base = 16px

// Font size of table and code.
$table-font-size = 14px

// Line height
$line-height-base = 1.6
$line-height-code-block = 1.4

NPM

Run子命令

bash
$ npm run server                              # 本地运行
$ npm run generate                            # 生成网站
$ npm run deploy                              # 部署
$ npm run clean                               # 清理生成的网站和cache

Hexo server命令选项

hexo server命令增加--open选项,每次预览本地网页的时候,直接用浏览器打开,不用手动去打开地址

json
// package.json文件
{
  "name": "hexo-site",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server --open" // 增加--open: 会自动用浏览器打开
  }
}

Github Pages

官网:https://pages.github.com/

网站仓库地址:

https://github.com/${user_name}/${user_name}.github.io

Blog 地址:

https://${user_name}.github.io/

限制:

https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages#usage-limits

  • 网站限制大小为 1GB
  • 网站内单个文件限制大小为 50MB
  • 一个月流量限制为 100GB;不过可以开 CDN

Updated at: