Hugo is one of the most popular open-source static site generators. With its amazing speed and flexibility, Hugo makes building websites fun again.

Hugo is a static site generator written in Go, optimized for speed and designed for flexibility.

Hugo is a static site generator written in Go, optimized for speed and designed for flexibility. With its advanced templating system and fast asset pipelines, Hugo renders a complete site in seconds, often less.

Due to its flexible framework, multilingual support, and powerful taxonomy system, Hugo is widely used to create:

  • Corporate, government, nonprofit, education, news, event, and project sites
  • Documentation sites
  • Image portfolios
  • Landing pages
  • Business, professional, and personal blogs
  • Resumes and CVs

启动服务

1
hugo server

创建帖子

1
2
hugo new posts/2024-12-03-hugo/index.md
hugo new content content/posts/xxxxx.md

部署到 Github

1
hugo --baseURL https://cjy1018.github.io/

目录结构

post 模板文件

1
├─archetypes

default.md

1
2
3
4
5
6
---
date: '{{ .Date }}'
title: {{ title }}
author: 'CJY'
tags: []
---

代码样式

1
2
3
├─assets
│  └─css
│      └─extended

assets\css\extended\blank.css

1
2
3
4
5
6
.post-content pre,
code {
  font-family: "consolas", monospace;
  font-size: 20px;
  line-height: 1.2;
}

archives, faq, search, space 模板文件; 帖子目录

1
2
3
4
5
├─content
│  └─posts # 帖子目录
│      ├─2024-11-20-llama-omni
│      ├─2024-11-20-whisper
│      └─2024-12-03-hugo

公开目录

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
├─public  
│  ├─archives  
│  ├─assets  
│  │  ├─css  
│  │  └─js  
│  ├─categories  
│  ├─faq  
│  ├─page  
│  │  └─1  
│  ├─posts  
│  │  ├─2024-11-20-llama-omni  
│  │  ├─2024-11-20-whisper  
│  │  ├─2024-12-03-hugo  
│  │  └─page  
│  │      └─1  
│  ├─search  
│  ├─space  
│  └─tags  
│      ├─asr  
│      │  └─page  
│      │      └─1  
│      └─skill  
│          └─page  
│              └─1

PaperMod 主题文件

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
└─themes  
    └─PaperMod  
        ├─.github  
        │  ├─ISSUE_TEMPLATE  
        │  └─workflows  
        ├─assets  
        │  ├─css  
        │  │  ├─common  
        │  │  ├─core  
        │  │  ├─extended  
        │  │  └─includes  
        │  └─js  
        ├─i18n  
        ├─images  
        └─layouts  
            ├─partials*  
            │  └─templates  
            │      └─_funcs  
            ├─shortcodes  
            └─_default  
                └─_markup

themes\PaperMod\layouts\partials\post_meta.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{{- $scratch := newScratch }}

{{- if not .Date.IsZero -}}
{{- $scratch.Add "meta" (slice (printf "<span title='%s'>Date: %s</span>" (.Date) (.Date | time.Format (default "January 2, 2006" site.Params.DateFormat)))) }}
{{- end }}

{{- if (.Param "ShowReadingTime") -}}
{{- $translatedReadTime := i18n "read_time" .ReadingTime }}
{{- $scratch.Add "meta" (slice (printf "Estimated Reading Time: %s" $translatedReadTime | default (printf "%d min" .ReadingTime))) }}
{{- end }}

{{- if not (.Param "hideAuthor") -}}
{{- with (partial "author.html" .) }}
{{- $scratch.Add "meta" (slice (printf "Author: %s" . | safeHTML)) }}
{{- end }}
{{- end }}

{{- with ($scratch.Get "meta") }}
{{- delimit . "&nbsp;|&nbsp;" | safeHTML -}}
{{- end -}}

辅助应用

  1. PaperMod 主题

  2. git / github 管理

  3. PicGo 图床(ip:15000/39000 /picgo)

  4. giscus 评论区

  5. flaticon 矢量图


教程链接

SonnyCalcr’s Blog   教学视频