Hugo 拥有超快的速度,强大的内容管理和强大的模板语言,使其非常适合各种静态网站。可以轻松安装在macOS,Linux,Windows等平台上,在开发过程中使用LiveReload可即时渲染更改

一、安装 Hugo

Mac 上安装 HUGO,很简单,通过 brew 可以快速安装

brew install hugo

检查安装版本信息

hugo version

二、使用 Hugo

1、创建网站

hugo new site iChochy 创建

其中 iChochy 为你的博客目录

目录结构

iChochy
├── archetypes
│   └── default.md
├── config.toml
├── content
├── data
├── layouts
├── static
└── themes

2、添加主题

a、下载主题

hyde主题为例 https://github.com/spf13/hyde

直接下载主题,放到themes目录中,或通过 git 方式添加主题

git submodule add https://github.com/spf13/hyde.git themes/hyde

b、修改配置

echo 'theme = "hyde"' >> config.toml

config.toml 文件内容

baseURL = "https://ichochy.com/"
languageCode = "en-us"
title = "My New Hugo Site"
theme = "hyde"

目录结构

iChochy
├── archetypes
│   └── default.md
├── config.toml
├── content
├── data
├── layouts
├── static
└── themes
└── hyde
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── archetypes
│   └── default.md
├── go.mod
├── images
│   ├── screenshot.png
│   └── tn.png
├── layouts
│   ├── 404.html
│   ├── _default
│   │   ├── baseof.html
│   │   ├── list.html
│   │   └── single.html
│   ├── index.html
│   └── partials
│   ├── head.html
│   ├── head_fonts.html
│   ├── hook_head_end.html
│   └── sidebar.html
├── static
│   ├── apple-touch-icon-144-precomposed.png
│   ├── css
│   │   ├── hyde.css
│   │   ├── poole.css
│   │   ├── print.css
│   │   └── syntax.css
│   └── favicon.png
└── theme.toml

3、编写内容

新建文章

hugo new posts/HelloWorld.md 新建

注:以 archetypes/default.md为模版创建

编写文章

vim content/posts/HelloWorld.md

HelloWorld.md 文件内容

---
title: "HelloWorld"
date: 2020-08-02T21:47:48+08:00
draft: true
--- ### HelloWorld https://ichochy.com

预览文章

hugo server -D 启动服务,访问 http://localhost:1313

目录结构

iChochy
├── archetypes
│   └── default.md
├── config.toml
├── content
│   └── posts
│   └── HelloWorld.md
├── data
├── layouts
├── resources
│   └── _gen
│   ├── assets
│   └── images
├── static
└── themes
└── hyde
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── archetypes
│   └── default.md
├── go.mod
├── images
│   ├── screenshot.png
│   └── tn.png
├── layouts
│   ├── 404.html
│   ├── _default
│   │   ├── baseof.html
│   │   ├── list.html
│   │   └── single.html
│   ├── index.html
│   └── partials
│   ├── head.html
│   ├── head_fonts.html
│   ├── hook_head_end.html
│   └── sidebar.html
├── static
│   ├── apple-touch-icon-144-precomposed.png
│   ├── css
│   │   ├── hyde.css
│   │   ├── poole.css
│   │   ├── print.css
│   │   └── syntax.css
│   └── favicon.png
└── theme.toml

部署

修改部署目录

修改 config.toml 文件

1、修改 bashURL 的部署域名

2、添加 publishDir = "docs",指定部署目录为 docs

config.toml 文件内容

baseURL = "https://ichochy.com/"
languageCode = "en-us"
title = "My New Hugo Site"
theme = "hyde"
publishDir = "docs"

生成静态文件

hugo -D 生成静态文件

目录结构

iChochy
├── archetypes
│   └── default.md
├── config.toml
├── content
│   └── posts
│   └── HelloWorld.md
├── data
├── docs
│   ├── 404.html
│   ├── apple-touch-icon-144-precomposed.png
│   ├── categories
│   │   ├── index.html
│   │   └── index.xml
│   ├── css
│   │   ├── hyde.css
│   │   ├── poole.css
│   │   ├── print.css
│   │   └── syntax.css
│   ├── favicon.png
│   ├── index.html
│   ├── index.xml
│   ├── posts
│   │   ├── helloworld
│   │   │   └── index.html
│   │   ├── index.html
│   │   └── index.xml
│   ├── sitemap.xml
│   └── tags
│   ├── index.html
│   └── index.xml
├── layouts
├── resources
│   └── _gen
│   ├── assets
│   └── images
├── static
└── themes
└── hyde
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── archetypes
│   └── default.md
├── go.mod
├── images
│   ├── screenshot.png
│   └── tn.png
├── layouts
│   ├── 404.html
│   ├── _default
│   │   ├── baseof.html
│   │   ├── list.html
│   │   └── single.html
│   ├── index.html
│   └── partials
│   ├── head.html
│   ├── head_fonts.html
│   ├── hook_head_end.html
│   └── sidebar.html
├── static
│   ├── apple-touch-icon-144-precomposed.png
│   ├── css
│   │   ├── hyde.css
│   │   ├── poole.css
│   │   ├── print.css
│   │   └── syntax.css
│   └── favicon.png
└── theme.toml

部署 GitHub Pages

将整个项目推送到 GitHub,然后在项目的 Settings 中开启的 GitHub Pages,并指定分支和目录 docs

就是可以直接在线访问了,如:https://ichochy.github.io

总结

Hugo 简单、易用、快速

模版化强大,只需要关心文章的编写

默认开启 LiveReload,修改后可以实时预览,免去手去刷新操作

还有很多强大的功能,如:摘要(Summary)、文章目录(TableOfContents)、相关推荐(Related)、多语言支持(i18n)、列表分页(Pagination)、简码(Shortcodes)等。

联系方式

网站:https://ichochy.com/

源文:https://ichochy.com/posts/20200802/

HUGO 创建属于自己的博客的更多相关文章

  1. 用Hugo在gitee上构建博客(Windows环境下)

    目录 用Hugo在gitee上构建博客(Windows环境下) 1.为什么要用gitee? 2.安装git 3.安装Hugo 4.创建远程仓库 5.搭建博客 (以下所有命令都在git bash中输入) ...

  2. Hugo + Github Pages 搭建个人博客

    尝试过 Hexo .GatsbyJs. Vuepress 搭建博客后,对这些工具最大的不满,就是运行速度以及打包速度. 后来看到 Hugo ,号称最快的静态站点生成器后. 尝试搭建博客,发现不管是运行 ...

  3. 应用github pages创建自己的个人博客

    首先你需要注册自己的github账号 1.登录或者注册github,登录之后点击右上角的“+”号,选择“New repository”菜单,创建仓库,用于存储和博客相关的源文件. 2.跳转页面将填写域 ...

  4. hexo+github创建属于自己的博客

    配置环境 安装Node(必须) 作用:用来生成静态页面的 到Node.js官网下载相应平台的最新版本,一路安装即可. 安装Git(必须) 作用:把本地的hexo内容提交到github上去. 安装Xco ...

  5. 创建自己的网站博客--Hexo

    原文地址:https://www.xingkongbj.com/blog/hexo/creat-hexo.html 安装环境 安装 node 下载对应版本并安装 node . 安装 Git Windo ...

  6. 如何用Hexo+Github创建自己的技术博客

    注册一个github GitHub官网.按照一般的网站注册登录执行就好了,不详细说. 安装git 安装很简单,一直下一步 git安装教程 很多教程里都说要配置环境变量,我本人安装过5次左右的git,一 ...

  7. SpringBoot使用Hibernate,实现自动创建数据库表【博客数据库设计】

    我们准备设计博客,那就要设计数据库. 我们可以使用Hibernate来自动生成数据库. 博客数据库的结构: 实体类: 博客 Blog 博客分类 Type 博客标签 Tag 博客评论 Comment 用 ...

  8. python基础[18]——使用django创建一个简易的博客网站

    一.页面实现 index.html base.html post.html header.html footer.html <!-- index.html--> {% extends 'b ...

  9. Hugo + github 搭建个人博客

    前言 很早以前就有想法,搭建一个个人的博客.没有实现的原因:一方面个人的服务器不太安全掉线,欠费,维护起来麻烦,另一方面,文章编辑发布起来也不方便. 后来了解到 github 提供了博客的功能,也一直 ...

随机推荐

  1. 解Bug之路-主从切换"未成功"?

    解Bug之路-主从切换"未成功"? 前言 数据库主从切换是个非常有意思的话题.能够稳定的处理主从切换是保证业务连续性的必要条件.今天笔者就来讲讲主从切换过程中一个小小的问题. 故障 ...

  2. 工具 | Typora + PicGo-Core 自动上传图片到图床

    0 前言 Markdown 是现在十分流行的标记式语言,在博客等很多场景中应用十分广泛.众所周知,Markdown 中的图片是以链接的形式存在的,不像 Word 等传统文本编辑器直接把图片嵌入文档中. ...

  3. [Kick Start] 2021 Round A

    题目:2021 Round-A . K-Goodness String 签到题,计算当前字符串的 K-Goodness Score ,然后与给出的 K 做差即可. #include <iostr ...

  4. [源码解析] 分布式任务队列 Celery 之启动 Consumer

    [源码解析] 分布式任务队列 Celery 之启动 Consumer 目录 [源码解析] 分布式任务队列 Celery 之启动 Consumer 0x00 摘要 0x01 综述 1.1 kombu.c ...

  5. 云计算和AI时代,运维应该如何做好转型?

    云计算和AI时代,运维应该如何做好转型? 今天我们来聊一聊,在云计算和AI时代,运维应该如何做好转型?今天的内容可以说是我们前面运维组织架构和协作模式转型的姊妹篇.针对运维转型这个话题,谈谈我的思考和 ...

  6. DAOS 分布式异步对象存储|数据平面

    DAOS 通过两个紧密集成的平面进行运转.数据平面处理繁重的运输操作,而控制平面负责进程编排和存储管理,简化数据平面的操作. 模块接口 I/O 引擎支持一个模块接口,该接口允许按需加载服务器端代码.每 ...

  7. Echarts概述

    1. Echarts概述 ECharts是百度开源的纯 Javascript 图表库,目前开源可以与highcharts相匹敌的一个图表库.支持折线图(区域图).柱状图(条状图).散点图(气泡图).K ...

  8. (十六)Struts2的标签库

    一.简介 Struts2的标签库使用OGNL为基础,大大简化了数据的输出,也提供了大量标签来生成页面效果,功能非常强大. 在早期的web应用开发中,jsp页面主要使用jsp脚本来控制输出.jsp页面嵌 ...

  9. Vim快速使用教程

    Vim Vim是从vi发展出来的一个文本编辑器.代码补完.编译及错误跳转等方便编程的功能特别丰富. Vi/Vim的使用 基本上分为三种模式,分别是命令模式(commad mode),输入模式(Inse ...

  10. [源码分析]并行分布式任务队列 Celery 之 子进程处理消息

    [源码分析]并行分布式任务队列 Celery 之 子进程处理消息 0x00 摘要 Celery是一个简单.灵活且可靠的,处理大量消息的分布式系统,专注于实时处理的异步任务队列,同时也支持任务调度.在前 ...