Please enable Javascript to view the contents

Hugo博客搭建

 ·  ☕ 2 分钟

Hugo 博客搭建

本地部署

推荐视频:手把手教你从 0 开始搭建自己的个人博客 |第二种姿势 | hugo

  1. 下载 Hugo,下载地址:GitHub

  2. 配置环境变量

  3. 创建自己的站点文件夹hugo new site myHugoSite

    生成的目录如下:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    
    PS C:\Users\Administrator\Desktop\myHogoSite> tree /f
    文件夹 PATH 列表
    卷序列号为 2A8A-01A5
    C:.
      config.toml
    
    ├─archetypes
          default.md
    
    
    ├─content
    ├─data
    ├─layouts
    ├─static
    └─themes
    
  4. 新建文章

    在 content 目录下生成博客hugo new 我的第一篇博客.md

    在 content/posts 目录下生成博客hugo new posts/我的第二篇博客.md

  5. 下载m10c 主题并配置

部署到 GitHub

  1. 创建远程仓库,仓库名必须为用户名.github.io
  2. 生成 public 文件夹hugo -t 主题名 -b https://用户名.github.io -D
  3. 然后就是一系列 git 操作
  4. 进入 public,初始化 git 仓库
  5. 添加到暂存区
  6. 提交仓库
  7. 连接远程仓库
  8. 推送到远程仓库

不清楚的命令可以通过hugo help查看

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$ hugo help
hugo is the main command, used to build your Hugo site.

Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.

Complete documentation is available at http://gohugo.io/.

Usage:
  hugo [flags]
  hugo [command]

Available Commands:
  config      Print the site configuration
  convert     Convert your content to different formats
  deploy      Deploy your site to a Cloud provider.
  env         Print Hugo version and environment info
  gen         A collection of several useful generators.
  help        Help about any command
  import      Import your site from others.
  list        Listing out various types of content
  mod         Various Hugo Modules helpers.
  new         Create new content for your site
  server      A high performance webserver
  version     Print the version number of Hugo

Flags:
  -b, --baseURL string         hostname (and path) to the root, e.g. http://spf13.com/
      --templateMetrics        display metrics about template executions
      --templateMetricsHints   calculate some improvement hints when combined with --templateMetrics
  -t, --theme strings          themes to use (located in /themes/THEMENAME/)
      --themesDir string       filesystem path to themes directory
      --trace file             write trace to file (not useful in general)
  -v, --verbose                verbose output
      --verboseLog             verbose logging
  -w, --watch                  watch filesystem for changes and recreate as needed

Additional help topics:
  hugo check   Contains some verification checks

Use "hugo [command] --help" for more information about a command.
分享
您的鼓励是我最大的动力
alipay QR Code
wechat QR Code

Vigilr
作者
Vigilr
大四学生