溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Hugo快速搭建Blog

發(fā)布時(shí)間:2020-06-15 09:41:55 來(lái)源:網(wǎng)絡(luò) 閱讀:419 作者:lzwxx 欄目:網(wǎng)絡(luò)安全

1 安裝

 ---------------------------

推薦二進(jìn)制安裝(簡(jiǎn)單、快速)

到 Hugo Releases 下載對(duì)應(yīng)的操作系統(tǒng)版本的Hugo二進(jìn)制文件(hugo或者h(yuǎn)ugo.exe)

Hugo Releases:h t tp s : / /g i th ub . com / go h ug oi o/ hu g o /r e l ea s e s

本文以Windows為例,所以下載:hugo_0.24.1_Windows-64bit.zip

下載之后解壓得到“hugo.exe”文件。

將hugo.exe所在的目錄添加到系統(tǒng)環(huán)境變量PATH下面,打開(kāi)cmd,輸入“hugo version”。

Hugo快速搭建Blog

 

2 創(chuàng)建站點(diǎn)&文章

---------------------------------------

想要?jiǎng)?chuàng)建站點(diǎn),一個(gè)命令搞定,切換到你想要?jiǎng)?chuàng)建站點(diǎn)的目錄,輸入:

Hugo快速搭建Blog

D:\git>hugo new site blog
Congratulations! Your new Hugo site is created in D:\git\blog.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>\<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.

Hugo快速搭建Blog

一個(gè)blog站點(diǎn)就創(chuàng)建好了。新建的站點(diǎn)目錄結(jié)果如下:

Hugo快速搭建Blog

blog/
    archetypes/ 
    doc/
    content/ 
    data/ 
    layouts/ 
    static/ 
    config.toml

Hugo快速搭建Blog

 

當(dāng)前的站沒(méi)有任何內(nèi)容,也沒(méi)做任何配置。

接下來(lái)切換到blog站點(diǎn)目錄,創(chuàng)建一篇文章:

D:\git>cd blog
D:\git\blog>hugo new about.md

該文件位于 blog/content/about.md目錄下。打開(kāi)編輯:

Hugo快速搭建Blog

+++
date = "2017-07-03T15:37:11+08:00"
tags = ["blog"]
title = "my first blog"

+++

### 這里使用markdown來(lái)編寫文章

Hugo快速搭建Blog

markdown 教程:ht tp : / / w o w ub u nt u .c o m / ma rk d  ow n/

 

3 安裝主題

 ---------------------------

站點(diǎn)一定要有主題,安裝主題應(yīng)該是最難的一步了,因?yàn)椴煌闹黝}設(shè)置方式也會(huì)有所不同。

Hugo themes:h t t ps : / / the m e s .g o h ug o . io/

你可以到上面的網(wǎng)站中挑選你喜歡的主題。然后,根據(jù)指引找到github項(xiàng)目地址進(jìn)行下載。

 

3.1 下載主題:

我使用的主題是:ht t ps : // gi t hu b . co m / w d/ hu g o- f  a b  r i c

把主題通過(guò)git克隆或直接下載到本地。放到 …/blog/themes/目錄下。

 

3.2 使用主題:

生成主題資源文件(hugo-fabric為主題名)

Hugo快速搭建Blog

D:\git\blog>hugo -t hugo-fabric
Started building sites ...
Built site for language en:
0 of 3 drafts rendered
0 future content
0 expired content
8 regular pages created
12 other pages created
0 non-page files copied
2 paginator pages created
1 tags created
1 categories created
total in 35 ms

Hugo快速搭建Blog

將\blog\themes\hugo-fabric\exampleSite\config.toml 替換 \blog\config.toml

注:config.toml文件是核心,對(duì)網(wǎng)站的配置多數(shù)需要修改該文件,而每個(gè)主題的配置又不完全一樣。

 

4 啟動(dòng)服務(wù)器

 ------------------------------

Hugo快速搭建Blog

D:\git\blog>hugo server
WARNING: Site config's rssURI is deprecated and will be removed in a future release. Set baseName in outputFormats.RSS.
Started building sites ...
Built site for language en:
0 draft content
0 future content
0 expired content
1 regular pages created
8 other pages created
0 non-page files copied
1 paginator pages created
1 tags created
0 categories created
total in 9 ms
Watching for changes in D:\git\blog\{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Hugo快速搭建Blog

 

打開(kāi)瀏覽器訪問(wèn):http://localhost:1313/

Hugo快速搭建Blog


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI