新建站点



命令

新建站点

BASH
        1hugo new site <项目名称>
      

命令查询

BASH
        1hugo --help
      

本地运行站点,浏览器地址为[ http://localhost:1313/ ]

BASH
        1hugo server --cleanDestinationDir
      

新建博文:[<项目名称>/Content]路径下创建文件夹/文件。

BASH
        1hugo new posts/first-blog.md
      

站点生成:[<项目名称>/Public]。

BASH
        1# hugo --baseURL="http://<域名>"
2hugo --baseURL="https://<域名>"
      

博文


文件类型

支持两种类型

markdown
org

预处理信息


格式

支持两种格式

toml
yaml
字段
date 创建时间
draft 草稿标识位
title 文章标题
  • toml

    toml
            1+++
    2date = '2026-08-09T18:53:18+08:00'
    3draft = false
    4title = 'First Blog'
    5+++	
          
  • yaml

    yaml
            1---
    2date: 2026-08-09T18:53:18+08:00
    3draft: false
    4title: "First Blog"
    5---
          

其他常用信息

lastmod 更新时间
weight 列表排序权重
yaml
        1lastmod: 2026-08-09T18:54:18+08:00
2weight: 1000
      

正文

markdown
        ---
date: 2026-08-09T18:53:18+08:00
draft: false
title: "First Blog"
---

This is my first blog.	
      

配置文件

hugo.toml

在根路径下。

支持两种格式

toml
yaml

修改配置

  1. 域名

    toml
            1# baseURL = 'http://<域名>/'
    2baseURL = 'https://<域名>/'
          
  2. 博客名称

    toml
            1title = '<博客名称>'
          

添加配置

  1. 语言
    影响日期格式

    toml
            1locale = 'zh-cn'
    2defaultContentLanguage = 'zh'
          
  2. 时区
    默认支持定时发表;若时区不一致,会导致博文无法查看

    toml
            1timeZone = 'Asia/Shanghai'
          
标题目录