当前位置:网站首页>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
边栏推荐
- 机器学习中如何使用数据集?
- 1-19 using CORS to solve interface cross domain problems
- 周少剑,很少见
- 1-3 using SQL to manage databases
- WinDbg debugging tool introduction
- Develop technology - get time 10 minutes ago
- Stinky tofu made by Grandma
- 国产数据库乱象
- Graduation project
- Niubi | the tools I have treasured for many years have made me free to fish with pay
猜你喜欢

RP prototype resource sharing - shopping app

Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could

B_ QuRT_ User_ Guide(32)

Excitatory neurotransmitter glutamate and brain health
![[micro service ~nacos] configuration center of Nacos](/img/c3/9d8fb0fd49a0ebab43ed604f9bd1cc.png)
[micro service ~nacos] configuration center of Nacos

Graduation project

Bloom filter
![[career planning for Digital IC graduates] Chap.1 overview of IC industry chain and summary of representative enterprises](/img/d3/68c9d40ae6e61efc10aca8bcc1f613.jpg)
[career planning for Digital IC graduates] Chap.1 overview of IC industry chain and summary of representative enterprises

机器学习适合女生学吗?

Pytorch quantitative practice (2)
随机推荐
VIM common shortcut keys
Ml & DL: introduction to hyperparametric optimization in machine learning and deep learning, evaluation index, over fitting phenomenon, and detailed introduction to commonly used parameter adjustment
B_ QuRT_ User_ Guide(33)
微服务链路风险分析
What is the experience of pairing with AI? Pilot vs alphacode, Codex, gpt-3
机器学习中如何使用数据集?
I want to know who I need to know to open a stock account? In addition, is it safe to open a mobile account?
Anti leakage family photo in attack and defense drill
1-18 create the most basic express server & API module for creating routes
Best wishes for Lao Wu's party
HDFS集中式缓存管理(Centralized Cache Management)
Qsort function and Simulation Implementation of qsort function
阿婆做的臭豆腐
微服務鏈路風險分析
京东与腾讯续签三年战略合作协议;起薪涨至26万元,韩国三星SK争相加薪留住半导体人才;Firefox 102 发布|极客头条
1-15 nodemon
B_ QuRT_ User_ Guide(34)
Uniapp rich text editor
Do machine learning jobs require graduate students?
Uniapp third party network request