用hugo快速创建一个博客

用hugo快速创建一个博客

背景

博客是技术人员日常记录的一个载体,开源的博客系统有很多,我最终选择了hugo。

安装hugo

直接看官方文档:https://gohugo.io/installation/

创建博客

命令

1hugo new site rushui.net -f yaml 
2cd rushui.net
3git init
4git submodule add https://github.com/hugo-theme/rs.git themes/rs
5echo "theme: rs" >> config.yaml
6hugo server

保留目录

blog中所有目录都是空的,所以只保留用到的目录和文件即可

1content #内容目录
2static #静态文件目录
3themes #主题目录
4config.yaml #配置文件

创建内容

1hugo new posts/blog-quickstart.md

posts/blog-quickstart.md 加入以下内容

 1---
 2title: "用hugo快速创建一个博客"
 3date: 2023-03-04T17:53:26+08:00
 4tags : ["如水"]
 5---
 6一个简单的go程序
 7```go
 8package main
 9import "fmt"
10func main(){
11  fmt.Println("hello world")
12}
13``` #去除后面空格

启动服务

1hugo server -D --poll 200ms

打开 http://localhost:1313/ 即可看到刚才加的内容

发布日期:2023-03-04 17:53 字数:76 用时 1分钟
tags:hugo 博客