当前位置:网站首页>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
边栏推荐
- 电脑设备管理器在哪里可以找到
- Windbg调试工具介绍
- Pytorch quantitative practice (2)
- Qsort function and Simulation Implementation of qsort function
- Study summary of dynamic routing between capsules
- Interesting plug-ins summary
- Introduction and example of template method mode
- 吴恩达的机器学习适合入门吗?
- Troubleshooting the problem of pytorch geometric torch scatter and torch spark installation errors
- Anaconda下安装Jupyter notebook
猜你喜欢

Error reporting: internal error XFS_ WANT_ CORRUPTED_ GOTO at line 1635 of file fs/xfs/libxfs/xfs_ alloc. c.

《安富莱嵌入式周报》第270期:2022.06.13--2022.06.19

RP prototype resource sharing - shopping app

Modify the name of the launched applet

Error filesystemexception: /data/nodes/0/indices/gttxk-hntgkhacm-8n60jw/1/index/ es_ temp_ File: structure needs cleaning

Excitatory neurotransmitter glutamate and brain health

What is the experience of pairing with AI? Pilot vs alphacode, Codex, gpt-3

Online education program user login and registration

Deployment and use of Nacos

部门新来了个阿里25K出来的,让我见识到了什么是天花板
随机推荐
[backtracking] full arrangement leetcode46
京东与腾讯续签三年战略合作协议;起薪涨至26万元,韩国三星SK争相加薪留住半导体人才;Firefox 102 发布|极客头条
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
ML&DL:机器学习和深度学习中超参数优化的简介、评估指标、过拟合现象、常用的调参优化方法之详细攻略
Win11电脑名如何更改?Win11更改电脑名的方法
Document layout analysis: a comprehensive survey 2019 paper learning summary
1-3 using SQL to manage databases
1-20 pre inspection request
1-13 express listens to get and post requests & processes requests
Stimulate new kinetic energy to develop digital economy in multiple places
The Jenkins download Plug-in can't be downloaded. Solution
Anti leakage family photo in attack and defense drill
How to use filters in jfinal to monitor Druid for SQL execution?
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
How to judge whether the JS object is empty
总结的一些内存问题
部门新来了个阿里25K出来的,让我见识到了什么是天花板
Is the stock account opened in qiniu safe? How to apply for a low commission stock account?
Label Contrastive Coding based Graph Neural Network for Graph Classification
Do machine learning jobs require graduate students?