-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatom.xml
More file actions
140 lines (124 loc) · 7.5 KB
/
atom.xml
File metadata and controls
140 lines (124 loc) · 7.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
<title type="text">keronScribe</title>
<subtitle type="html">不小心成為後端工程師之後的修練筆記</subtitle>
<updated>2021-01-24T19:40:56+09:00</updated>
<id>https://keronscribe.github.io/</id>
<link rel="alternate" type="text/html" href="https://keronscribe.github.io/" />
<link rel="self" type="application/atom+xml" href="https://keronscribe.github.io/atom.xml" />
<author>
<name>Cian</name>
<uri>https://keronscribe.github.io/</uri>
<email>keronScribe@gmail.com</email>
</author>
<rights>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</rights>
<generator uri="https://gohugo.io/" version="0.80.0">Hugo</generator>
<entry>
<title type="text">Building Hugo</title>
<link rel="alternate" type="text/html" href="https://keronscribe.github.io/posts/building-hugo/" />
<id>https://keronscribe.github.io/posts/building-hugo/</id>
<updated>2021-01-24T19:39:51+09:00</updated>
<published>2021-01-24T16:56:32+09:00</published>
<author>
<name>Cian</name>
<uri>https://io-oi.me/</uri>
<email>keronScribe@gmail.com</email>
</author>
<rights>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</rights><summary type="html">使用 hugo 建立部落格 最近覺得自己用 WordPress 架的部落格因為功能太多了,也不支持 M……</summary>
<content type="html"><h1 id="使用-hugo-建立部落格">使用 hugo 建立部落格</h1>
<p>最近覺得自己用 WordPress 架的部落格因為功能太多了,也不支持 Markdown,寫 blog 的成本變得挺高的,所以想要來見一個單純一點的地方放自己的筆記。一切精簡化,所以也不想煩惱域名之類,最後選了沒有用過的 Hugo 架在 GitHub 上。</p>
<h2 id="需求">需求</h2>
<ol>
<li>brew</li>
<li>Git</li>
</ol>
<h2 id="安裝-hugo">安裝 hugo</h2>
<ol>
<li>
<p>安裝</p>
<pre><code>brew install hugo
</code></pre></li>
<li>
<p>確認安裝狀況</p>
<pre><code>hugo version
</code></pre><p>印出版本代表有安裝成功</p>
<pre><code>Hugo Static Site Generator v0.80.0/extended darwin/amd64 BuildDate: unknown
</code></pre></li>
<li>
<p>用 hugo 生成 blog</p>
<pre><code>hugo new site {blog name}
</code></pre><p>這時候用 <code>ls</code> 可以發現有一個你的 blog name 的資料夾, <code>cd</code> 到裡面看大概有這些東西,你現在在的這個資料夾就是 blog 的根目錄</p>
<pre><code>drwxr-xr-x 3 username staff 96 Jan 24 15:01 archetypes
-rw-r--r-- 1 username staff 82 Jan 24 15:01 config.toml
drwxr-xr-x 2 username staff 64 Jan 24 15:01 content
drwxr-xr-x 2 username staff 64 Jan 24 15:01 data
drwxr-xr-x 2 username staff 64 Jan 24 15:01 layouts
drwxr-xr-x 2 username staff 64 Jan 24 15:01 static
drwxr-xr-x 2 username staff 64 Jan 24 15:01 themes
</code></pre></li>
<li>
<p>下載主題
到 <a href="https://themes.gohugo.io/">https://themes.gohugo.io/</a> 選一個主題。
跟著該主題在 download 裡的教學下載。這裡以我選的主題 meme 為例。</p>
<pre><code>~ $ cd blog // 剛剛 hugo 幫你用 blog name 創建的資料夾
~/blog $ git init
~/blog $ git submodule add --depth 1 https://github.com/reuixiy/hugo-theme-meme.git themes/meme
</code></pre><p>下載完成後可以 <code> cd themes/</code> 去確認你有下載完成。</p>
</li>
<li>
<p>設置主題</p>
<p><strong>提示</strong>: 每一個主題的設置部分可能會有不同,請參考 GitHub 上面的教學。
meme 提供簡單的配置檔,可以直接拿這個檔案取代掉原本的 toml 檔案。</p>
<pre><code>~/blog $ rm config.toml &amp;&amp; cp themes/meme/config-examples/zh-cn/config.toml config.toml
</code></pre><p>如果有進行其他設定,或者不想直接用這個檔案,可以手動修改主題欄位。</p>
</li>
</ol>
<h2 id="開始寫文章">開始寫文章</h2>
<ol>
<li>建立文章
<pre><code>~/blog $ hugo new &quot;posts/hello-world.md&quot;
</code></pre><p>這時 hugo 會在 <code>blog/content/</code> 底下創建
<code>posts/hello-world.md</code>,想確認的話可以自己 <code>cd</code> 進去用 <code>ls</code> 確認。
然後我會用 VScode 打開檔案寫文章。
寫完之後存擋就可以了</p>
</li>
<li>預覽自己寫好的文章
<pre><code>~/blog $ hugo server
</code></pre><p>這個指令會跑一個在本地的 server,可以方便我們預覽文章。
如果你的檔案還是草稿,但你想要預覽,可以在後面加上 flag <code>-D</code> 來檢視還是草稿的文章。</p>
</li>
</ol>
<h2 id="部署到-github">部署到 GitHub</h2>
<ol>
<li>
<p>到你自己的 GitHub 上去,點開 Create a new repository,Repository name 一定要寫全小寫的自己 GitHub 名字+github.io
這個我沒有深究原因,大概是因為網址地址會長這樣所以直接這樣命名吧。如果有人知道詳細原因可以再留言和我說。</p>
</li>
<li>
<p>Build</p>
<pre><code>hugo --baseUrl=&quot;https://keronscribe.github.io/&quot;
</code></pre><p>這個指令會在根目錄下生成一個 public 資料夾,裡面是把 content 得東西轉成 html 的檔案。這就是我們要推上 GitHub 的東西們。</p>
</li>
<li>
<p>git init 本地 public 資料夾
到 <code>/public/</code> 裡,init 一個 git repo</p>
<pre><code>git init
git add .
git commit -m &quot;my 1st commit&quot;
</code></pre></li>
<li>
<p>連到遠端</p>
<pre><code>git remote add origin https://github.com/{github account}/{github repo}.git // 這一行在 GitHub 的初始 repo 裡應該也有
</code></pre><p>推上去</p>
<pre><code>git push -u origin master
</code></pre></li>
<li>
<p>完成。現在就可以透過你的 baseURL 連到你的 blog 了。
有時候 deploy 可能需要花一些些時間,另外有可能 GitHub page 也要打開。</p>
</li>
</ol>
<p>Hugo 還有不少相關指令可以使用,有興趣的朋友可以自己上 <a href="https://gohugo.io/commands/hugo/">館方網站</a>看。
感謝你的閱讀,希望大家架 Blog 順利。</p>
</content>
</entry>
</feed>