当前位置:网站首页>Golang application ━ installation, configuration and use of Hugo blog system
Golang application ━ installation, configuration and use of Hugo blog system
2022-06-30 22:12:00 【Use this name for the time being】
First make complaints about it , Several articles about the five elements and eight trigrams were csdn Prompt violation of national laws ... We can only consider self construction blog, Can't be tied .
Coincidentally, I have always wanted to set up a local markdown System , After all md It's always the first thing to do locally .
current hugo It's good to try , Send a document to record the installation process .
Manually download the whole process , no need git
One 、 Prepare execution file hugo.exe
Binary system
Get ready-made directly ~~
Execution file download website :https://github.com/gohugoio/hugo/releasesSource code generation
Source download website :https://github.com/gohugoio/hugo
Unzip all , Use commandgo build, There is no need for more nonsense ... ha-ha .
Be careful , If I remind youbuildno , Please check your go Is the version the latest , Used in writing this articlego 1.18.3, If it isgo 1.17.xVersion cannot be generated normally .
Two 、 Generate blogTest project
take hugo.exe Place on D:/test/hugo In the table of contents , Use cmd command
hugo new site blogTest
Generate... After execution D:/test/hugo/blogTest Catalog , This directory is the current blogTest The root directory of the project , And then put hugo.exe Move to the real root directory , Later orders need him .
3、 ... and 、 Installation template testTpl
Official template download address :https://themes.gohugo.io/
Suppose you download the template testTpl, Download and unzip to D:/test/hugo/blogTest/themes/testTpl in .
Four 、 Create articles first.md and about.md
stay D:/test/hugo In the table of contents , Use cmd command
hugo new first.md
hugo new posts/about.md
The directory and md file :D:/test/hugo/blogTest/content/first.mdD:/test/hugo/blogTest/content/posts/about.md.
about.md The contents of the document are as follows :
---
title: "About"
date: 2022-06-26T16:15:50+08:00
draft: true
---
Pay attention to this draft: true, It means this article is a draft , Later in the article .
In the end --- Write a sentence below ## ok , Test it ,markdown I don't speak much language .
5、 ... and 、 Self built server
stay D:/test/hugo In the table of contents , Use cmd command
hugo server --theme=testTpl --buildDrafts --watch
- theme: What template to use ;
- buildDrafts: Show the draft as well ;
- watch: Any article modification will be refreshed in real time ;

go server The command will automatically enable the built-in web server, It is used in the native browser by default http://127.0.0.1:1313 open , Please pay attention to the result prompt of the terminal for the specific port number .
6、 ... and 、 Generating static files
stay D:/test/hugo In the table of contents , Use cmd command
- Normal mode
hugo
- Draft also generates patterns (
-Byes--buildDraftsAbbreviation )
hugo -B
- Various command modes
hugo --theme=testTpl --buildDrafts

The generated static files are in D:/test/hugo/blogTest/public, Including articles 、 style 、 Multimedia files, etc .
At this time will be public All files in the directory can be uploaded to the hosting server for external use .
7、 ... and 、 The configuration file
There are two key configurations , If these two places are not configured , The generated static file cannot be displayed or used normally :
- The system configuration
stayD:/test/hugo/blogTest/config.tomlContent modificationbaseURLAnd newtheme.baseURLFor the project at web server Root directory on ( You can add a domain name or not , But you need to conform to the rules of absolute and relative directories ).contentIt is the local directory where the article is located , You can store the original article separately ,hugo The system belongs to another directory .themeIs the name of the template used .uglyURLsUse the title name as the file name or as the directory name , The default isfalse, If it is used locally , It is recommended to usetrue
baseURL = 'http://127.0.0.1/hugo/blogTest/public/'
contentdir = "c:/blog/test"
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = "testTpl"
uglyURLs = true
- Article configuration
takeD:/test/hugo/blogTest/content/posts/about.mdIn the articledraft: trueChange it todraft: false, Otherwise, direct usehugoIf you order , Drafts do not generate static files , It will not appear in the list of articles ,go serverThe same is true for orders .
This casefirst.mdandabout.mdThere is only... In the documentabout.mdNon draft , namelydraft: false, So usehugoCommand to generate a static file directly , There will be a homepage with only one article .
8、 ... and 、 Start blogging
If you use Obsidian Blogging , So that the accessories can be used normally , The recommended setting is shown in the figure , The key is Insert a relative path based on the current note .
The details of the obsidian Usage method :《obsidian coordination hugo Use , Give Way markdown Local editing software and online seamless connection 》
Again, I strongly recommend : In actual use, try to store the original blog in other directories ,hugo In another directory .
stay hugo Ofconfig.tomlSet incontentdirDirectory to read the original blog .
Reference resources :
Hugo Get started quickly
The world's fastest static blog generation tool Hugo Getting started tossing
Enable Ugly URL
To configure Hugo
边栏推荐
- Qsort function and Simulation Implementation of qsort function
- 1-13 express listens to get and post requests & processes requests
- The Jenkins download Plug-in can't be downloaded. Solution
- Nansen复盘加密巨头自救:如何阻止百亿多米诺倾塌
- Uniapp third party network request
- Starting from pg15 xid64 ticket skipping again
- JD and Tencent renewed the three-year strategic cooperation agreement; The starting salary rose to 260000 yuan, and Samsung sk of South Korea scrambled for a raise to retain semiconductor talents; Fir
- 盘点华为云GaussDB(for Redis)六大秒级能力
- Look at the top 10 capabilities of alicloud cipu
- 1-20 pre inspection request
猜你喜欢

Is there a shortage? No need to download the free online resources! 2022 favorites must have it!

Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)

Why does the computer speed slow down after vscode is used for a long time?

A new one from Ali 25K came to the Department, which showed me what the ceiling is

Windbg调试工具介绍

Tencent has been conducting advanced automated functional testing for 3 years. It is a gift to you who are confused in manual testing

周少剑,很少见

Do machine learning jobs require graduate students?

Excitatory neurotransmitter glutamate and brain health

Graduation project
随机推荐
Label Contrastive Coding based Graph Neural Network for Graph Classification
1-13 express listens to get and post requests & processes requests
Anti leakage family photo in attack and defense drill
How to use filters in jfinal to monitor Druid for SQL execution?
去中心化交易所系统开发技术原理丨数字货币去中心化交易所系统开发(说明案例)
Technical principle of decentralized exchange system development - digital currency decentralized exchange system development (illustrative case)
B_ QuRT_ User_ Guide(34)
Excuse me, can I open an account for the company? Is it safe? All the answers you want are here
The Three Musketeers: One for All!
Zhoushaojian, rare
Best wishes for Lao Wu's party
Do machine learning jobs require graduate students?
5G 在智慧医疗中的需求
电脑版微信文件存储在哪个文件夹可以找到
"Trust machine" empowers development
Apache服务器OpenSSL升级
HDFS集中式缓存管理(Centralized Cache Management)
电脑设备管理器在哪里可以找到
Document layout analysis: a comprehensive survey 2019 paper learning summary
Femas:云原生多运行时微服务框架