在VPS下载hugo源码并进行安装,生成个人网站的完整步骤

1.安装git

2.安装go

下载
wget https://go.dev/dl/go1.24.3.linux-amd64.tar.gz

rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.3.linux-amd64.tar.gz

#Add /usr/local/go/bin to the PATH environment variable
export PATH=PATH:/usr/local/go/bin
source ~/.bashrc

#确认go安装成功:
go version

3.下载编译安装hugo:

#Hugo Extended 支持:
#SCSS / SASS 解析和编译
#PostCSS 集成
#一些高级主题(如 lotusdocs)必须依赖它
#普通版 Hugo 无法编译 SCSS,导致模块加载失败。

CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest

#如果上面指令卡住,可以分布进行:
git clone https://github.com/gohugoio/hugo.git
cd hugo
#切换到最新版本:
git checkout v0.147.5
#这条命令会基于当前目录的 go.mod,构建出 Hugo Extended 可执行文件,并安装到HOME/go/bin。
CGO_ENABLED=1 go install -tags extended


#确认hugo是否安装成功:
#执行:
ls HOME/go/bin/hugo
/root/go/bin/hugo

#将HOME/go/bin 添加到你的 PATH:
echo 'export PATH=PATH:HOME/go/bin' >> ~/.bashrc
source ~/.bashrc

执行:hugo version

Run these commands to create a Hugo site with the Ananke theme.

hugo new site quickstart
cd quickstart

Edit the hugo.toml configuration file

参考:https://github.com/colinwilson/lotusdocs
使用Hugo Module 模式,配置 hugo.toml,下载主题。

baseURL = 'http://www.wangshumian.com/'
languageCode = 'en-us'
title = 'My New Hugo Site'
enableEmoji = true

[module]
    [[module.imports]]
        path = "github.com/colinwilson/lotusdocs"

[markup]
  [markup.goldmark.renderer]
    unsafe = true
  [markup.tableOfContents]
    startLevel = 1
    endLevel = 3
  [markup.goldmark.parser.attribute]
    block = true

继续

rm -rf themes
hugo mod init github.com/yourusername/wsmlite
cat go.mod
#module github.com/yourusername/wsmlite
#go 1.24.3
hugo mod tidy

执行:
go list -m all
确认主题lotusdocs 被正确拉取。

生成示例内容

#创建页面目录结构(推荐使用 docs/)
hugo new docs/getting-started/index.md
hugo new docs/installation/index.md
hugo new docs/configuration/index.md
hugo new docs/faq/index.md
#编辑getting-started index.md 文件内容
---
title: "Getting Started"
description: "本页面介绍如何快速上手 Hugo + lotusdocs 主题建站。"
lead: "快速构建你的第一个 Hugo 网站"
date: 2025-05-24
lastmod: 2025-05-24
draft: false
menu:
  docs:
    parent: ""
    weight: 10
---

##  快速开始

欢迎使用 Hugo + lotusdocs 主题!本教程将帮助你快速生成一个现代化的静态网站。

### 环境准备

- 已安装 Hugo Extended 版本
- 已初始化 Hugo Module
- 已配置 lotusdocs 主题

### 项目结构

```bash
.
├── content/
│   └── docs/
│       └── getting-started/
│           └── index.md  ← 本页面
├── hugo.toml
├── go.mod
</code></pre>

#其他每个 index.md 中输入
menu:
  docs:
    parent: "Getting Started"  # 或其他章节标题
    weight: 20
#lotusdocs 会根据 menu.docs 自动生成侧边栏导航。

#启动本地服务器预览
hugo server --buildDrafts
#正式发布
hugo

<pre><code class="line-numbers">```html

主要依靠chatgpt解决问题,有参考:https://gohugo.io/getting-started/quick-start