Featured image of post 【Hugo之路 4】开始创作之旅

【Hugo之路 4】开始创作之旅

创建新文章

新的文章会自动生成在 content 目录下

我习惯每篇文章都单独一个文件夹

1
hugo new post/folder/index.md
  • folder:自定义的文件夹名
  • index:官方建议的命名,否则可能导致格式问题

参考:Page Bundles | Hugo (gohugo.io)

配置分类/标签

标签也一样的配置,不过目录是content\tags

  1. 创建分类:在content\categories下以分类名创建新的文件夹
  2. 创建分类配置文件:content\categories\分类名\_index.md

以创建“Blog”分类为例,配置如下:

1
2
3
4
5
6
7
title: "Blog"
description: "博客的建造工艺"
slug: "blog"
image: "blog.jpg"
style:
    background: "#2a9d8f"
    color: "#fff"
  • image:为content\categories\分类名\目录下的图片文件名
  • style:设置分类/标签的显示效果

编辑文章

1
2
3
4
5
slug: xxx
categories:
    - Blog
tags:
    - Hugo
  • slug:文章 url 为exmaple.com/xxx/
  • categories: 分类
  • tags:标签

发布上线

  1. 参照【Hugo 之路 番外 1】自动构建并上传到 github 创建git.bat文件
  2. 运行git.bat即可
Licensed under CC BY-NC-SA 4.0
最后更新于 Apr 01, 2022 02:00 CST
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计