作业一 云服务器的基本使用

学号:21311162

姓名:伍开钰

Have a good day !

安装 Hugo

链接:https://gohugo.io/installation/linux/

Prerequisites

  • Git
  • Go

安装

# 使用 Go 安装
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
# 配置 Go 的 bin 路径
echo 'export PATH=$PATH:/pathto/go/bin' >> ~/.zshrc
source ~/.zshrc
# 查看 hugo 版本
hugo version

Quick Start

Create a site

# 在 quickstart 目录中为您的项目创建目录结构。
hugo new site quickstart
cd quickstart
git init
# 将 yinyang 主题克隆到 themes 目录中,并将其作为 Git 子模块添加到您的项目中。
git submodule add https://github.com/joway/hugo-theme-yinyang.git
# 在站点配置文件中添加一行,指示当前主题。
echo "theme = 'yinyang'" >> hugo.toml
# 启动Hugo的开发服务器来查看该站点。
hugo server

Add content

# 向您的网站添加新页面。
hugo new content posts/my-first-post.md

# Hugo 在 content/posts 目录中创建了该文件。使用编辑器打开文件。
# 请注意,前面的 draft 值为 true 。默认情况下,Hugo 在您构建网站时不会发布草稿内容。了解有关草稿、未来和过期内容的更多信息。
# 当对新内容感到满意时,请将 front Matter draft 参数设置为 false 。
+++
title = 'My First Post'
date = 2024-01-14T07:07:07+01:00
draft = true
+++
## Introduction

This is **bold** text, and this is *emphasized* text.

Visit the [Hugo](https://gohugo.io) website!

# 保存草稿内容
hugo server --buildDrafts
hugo server -D    # 或

Configure the site

使用编辑器打开项目根目录中的站点配置文件 (hugo.toml)。

baseURL = 'https://example.org/'    # 为您的生产站点设置 baseURL 。该值必须以协议开头并以斜杠结尾,如上所示。
languageCode = 'en-us'    # 将 languageCode 设置为您的语言和区域。
title = 'My New Hugo Site'    # 为您的生产站点设置 title 。

Publish the site

在此步骤中,您将发布您的网站,但不会部署它。

当您发布站点时,Hugo 在项目根目录的 public 目录中创建整个静态站点。这包括 HTML 文件以及图像、CSS 文件和 JavaScript 文件等资产。

当您发布网站时,您通常不希望包含草稿、未来或过期的内容。

# 命令很简单。
hugo