Contents

麦子米的个人分享网站创建了

麦子米的独立网站创建了

我要搭建个人网站了,就启用个人域名。

使用了一个hugo程序,主题是LoveIt

安装部署也很简单啦

第一步:安装 Hugo

Windows版本安装:

下载地址:https://github.com/gohugoio/hugo/releases 下载Hugo Window版本 :hugo_0.119.0_windows-amd64.zip 我这安装的extended版本:hugo_extended_0.119.0_windows-amd64.zip

解压后把hugo.exe文件放到C:\Windows\System32 目录下,也可以把hugo.exe设置环境变量中

E:\project\hugo_extended_0.119.0_windows-amd64>hugo version
hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended windows/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=gohugoio

如上所示能正常显示版本号,即表示hugo安装成功。

第二步:创建站点

E:\project\hugo_extended_0.119.0_windows-amd64>hugo new site blog
Congratulations! Your new Hugo site was created in E:\project\hugo_extended_0.119.0_windows-amd64\blog.

Just a few more steps...

1. Change the current directory to E:\project\hugo_extended_0.119.0_windows-amd64\blog.
2. Create or install a theme:
   - Create a new theme with the command "hugo new theme <THEMENAME>"
   - Install a theme from https://themes.gohugo.io/
3. Edit hugo.toml, setting the "theme" property to the theme name.
4. Create new content with the command "hugo new content <SECTIONNAME>\<FILENAME>.<FORMAT>".
5. Start the embedded web server with the command "hugo server --buildDrafts".

See documentation at https://gohugo.io/.

E:\project\hugo_extended_0.119.0_windows-amd64>cd blog

第三步:添加LoveIt 主题

下载主题并添加至站点theme目录:

git init
git submodule add https://github.com/dillonzq/LoveIt.git themes/LoveIt

第四步: 基础配置

如下模板

baseURL = "http://example.org/"

# 更改使用 Hugo 构建网站时使用的默认主题
theme = "LoveIt"

# 网站标题
title = "我的全新 Hugo 网站"

# 网站语言, 仅在这里 CN 大写 ["en", "zh-CN", "fr", "pl", ...]
languageCode = "zh-CN"
# 语言名称 ["English", "简体中文", "Français", "Polski", ...]
languageName = "简体中文"
# 是否包括中日韩文字
hasCJKLanguage = true

# 作者配置
[author]
  name = "xxxx"
  email = ""
  link = ""

# 菜单配置
[menu]
  [[menu.main]]
    weight = 1
    identifier = "posts"
    # 你可以在名称 (允许 HTML 格式) 之前添加其他信息, 例如图标
    pre = ""
    # 你可以在名称 (允许 HTML 格式) 之后添加其他信息, 例如图标
    post = ""
    name = "文章"
    url = "/posts/"
    # 当你将鼠标悬停在此菜单链接上时, 将显示的标题
    title = ""
  [[menu.main]]
    weight = 2
    identifier = "tags"
    pre = ""
    post = ""
    name = "标签"
    url = "/tags/"
    title = ""
  [[menu.main]]
    weight = 3
    identifier = "categories"
    pre = ""
    post = ""
    name = "分类"
    url = "/categories/"
    title = ""

# Hugo 解析文档的配置
[markup]
  # 语法高亮设置 (https://gohugo.io/content-management/syntax-highlighting)
  [markup.highlight]
    # false 是必要的设置 (https://github.com/dillonzq/LoveIt/issues/158)
    noClasses = false

第五步: 创建文章

在content目录下,创建posts/my-first-post.md文件,文件内容为:

---
title: "My First Post"
date: 2019-03-26T08:47:11+01:00
draft: false
---

第六步: 在本地启动网站

hugo serve  -D

去查看 http://localhost:1313.

启动后,根据提示访问地址:http://localhost:1313/ 即可查看博客网页

第七步: 构建网站

当你准备好部署你的网站时, 运行以下命令:

hugo -D

会生成一个 public 目录, 其中包含你网站的所有静态内容和资源. 现在可以将其部署在任何 Web 服务器上.