六一的部落格


关关难过关关过,前路漫漫亦灿灿。




说明

-
Github Pages 使用Github提供的免费服务部署静态博客
Hugo 本地构建静态网页
anubis 主题

安装Hugo

Github

官网


方法一: 使用go安装

Windows

  1. 安装go

    官网下载

    • 环境变量
      1# go
      2export PATH=/usr/local/go/bin:$PATH
      3export GOROOT=/usr/local/go
      4export GOPATH=/Users/USERNAME/go
      5export GOBIN=/Users/USERNAME/go/bin
      6
      7# go安装的软件
      8export PATH=$GOBIN:$PATH
  2. 安装hugo

    • 如若遇上网络不佳, 配置代理
      1go env -w GOPROXY=https://goproxy.cn,direct
      2go env -w GOSUMDB=off
    • 安装并验证
      1go install github.com/gohugoio/hugo@latest
      2hugo env -v
    • 部分主题需用hugo_extended提供的支持

方法二: 使用homebrew安装

macOS

1brew install hugo

创建站点项目

  1. 新建站点

    1hugo new site /site/path
  2. 站点项目结构

    文件 说明
    config.toml 配置文件;yaml格式也可以
    content 存放blog;支持md和org
    theme 存放主题
    public 生成的静态页面;同步到Github项目
    archetypes 文章模版
  3. 新建博客

    所在目录为 ./content/post

    1hugo new post/first-blog.org

使用主题anubis

anubis on hugo

anubis on github

  1. 将主题作为项目子模块

    1git init
    2git submodule add https://github.com/mitrichius/hugo-theme-anubis.git themes/anubis
  2. 使用anubis提供的模板

    ./themes/anubis/exampleSite/

    1cp themes/anubis/exampleSite/config.toml .
    2cp themes/anubis/exampleSite/content/. content
  3. 主题说明

    • 提供标签(tags)和分类(categories)功能, 提供文章列表(archives)
    • 文章存放到content/post目录下
  4. 文章模板

    yaml

     1---
     2author: "author"
     3title: "article title"
     4date: "2023-03-17"
     5description: "article description"
     6tags: [
     7"tag-1",
     8"tag-2",
     9]
    10categories: [
    11"category",
    12]
    13---
    14简单介绍
    15
    16<!- -more- ->
    17
    18正文

    移除 - - 之间的空格


构建静态网页

选项 说明 构建或测试
- -theme=anubis 设置主题 -t anubis both
- -watch 修改文件后自动刷新浏览器 -w server
- -buildDrafts 包括标记为draft的笔记 -D both
- -buildFuture 包括新发布笔记;检查date选项 -F both
- -baseURL=" http://enjoy61.github.io/ " 未配置编译,GithubPage部署会丢失样式 both
- -cleanDestinationDir 将public文件夹中不再使用的文件删除 hugo

移除 - - 之间的空格


本地测试

  • 查询server选项

    参考

    1hugo help server
  • 访问 http://localhost:1313/

    1hugo server --theme=anubis --watch
    2# hugo server

构建静态页面

生成文件路径 ./public/

1hugo --theme=anubis --baseURL="https://enjoy61.github.io/"
2# hugo

在Github创建项目

  1. 创建仓库

    • 仓库名为enjoy61.github.io
    • 使用Github Pages提供的免费服务需公开项目
  2. 测试服务: 为github设置主题

    添加_config.yaml文件

    1remote_theme: pages-themes/midnight@v0.2.0
  3. 将public文件夹提交到仓库


使用Hugo+GitHub搭建静态博客



说明

-
Github Pages 使用Github提供的免费服务部署静态博客
Hugo 本地构建静态网页
anubis 主题

安装Hugo

Github

官网


方法一: 使用go安装

Windows

  1. 安装go

    官网下载

    • 环境变量
      1# go
      2export PATH=/usr/local/go/bin:$PATH
      3export GOROOT=/usr/local/go
      4export GOPATH=/Users/USERNAME/go
      5export GOBIN=/Users/USERNAME/go/bin
      6
      7# go安装的软件
      8export PATH=$GOBIN:$PATH
  2. 安装hugo

    • 如若遇上网络不佳, 配置代理
      1go env -w GOPROXY=https://goproxy.cn,direct
      2go env -w GOSUMDB=off
    • 安装并验证
      1go install github.com/gohugoio/hugo@latest
      2hugo env -v
    • 部分主题需用hugo_extended提供的支持

方法二: 使用homebrew安装

macOS

1brew install hugo

创建站点项目

  1. 新建站点

    1hugo new site /site/path
  2. 站点项目结构

    文件 说明
    config.toml 配置文件;yaml格式也可以
    content 存放blog;支持md和org
    theme 存放主题
    public 生成的静态页面;同步到Github项目
    archetypes 文章模版
  3. 新建博客

    所在目录为 ./content/post

    1hugo new post/first-blog.org

使用主题anubis

anubis on hugo

anubis on github

  1. 将主题作为项目子模块

    1git init
    2git submodule add https://github.com/mitrichius/hugo-theme-anubis.git themes/anubis
  2. 使用anubis提供的模板

    ./themes/anubis/exampleSite/

    1cp themes/anubis/exampleSite/config.toml .
    2cp themes/anubis/exampleSite/content/. content
  3. 主题说明

    • 提供标签(tags)和分类(categories)功能, 提供文章列表(archives)
    • 文章存放到content/post目录下
  4. 文章模板

    yaml

     1---
     2author: "author"
     3title: "article title"
     4date: "2023-03-17"
     5description: "article description"
     6tags: [
     7"tag-1",
     8"tag-2",
     9]
    10categories: [
    11"category",
    12]
    13---
    14简单介绍
    15
    16<!- -more- ->
    17
    18正文

    移除 - - 之间的空格


构建静态网页

选项 说明 构建或测试
- -theme=anubis 设置主题 -t anubis both
- -watch 修改文件后自动刷新浏览器 -w server
- -buildDrafts 包括标记为draft的笔记 -D both
- -buildFuture 包括新发布笔记;检查date选项 -F both
- -baseURL=" http://enjoy61.github.io/ " 未配置编译,GithubPage部署会丢失样式 both
- -cleanDestinationDir 将public文件夹中不再使用的文件删除 hugo

移除 - - 之间的空格


本地测试

  • 查询server选项

    参考

    1hugo help server
  • 访问 http://localhost:1313/

    1hugo server --theme=anubis --watch
    2# hugo server

构建静态页面

生成文件路径 ./public/

1hugo --theme=anubis --baseURL="https://enjoy61.github.io/"
2# hugo

在Github创建项目

  1. 创建仓库

    • 仓库名为enjoy61.github.io
    • 使用Github Pages提供的免费服务需公开项目
  2. 测试服务: 为github设置主题

    添加_config.yaml文件

    1remote_theme: pages-themes/midnight@v0.2.0
  3. 将public文件夹提交到仓库