You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _learn/03-hugo-go-netlify.md
+62-54Lines changed: 62 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,12 @@ You can also set up Docker and then use this [Docker image](https://hub.docker.c
33
33
34
34
```
35
35
$ hugo version
36
-
Hugo Static Site Generator v0.74.3/extended darwin/amd64 BuildDate: unknown
36
+
hugo v0.135.0+extended darwin/amd64 BuildDate=2024-09-27T13:17:08Z VendorInfo=brew
37
37
```
38
38
39
39
## Starting a Hugo site
40
40
41
-
For a Hugo static site, you can choose your specific theme after you create the source files. The theme we'll use in this tutorial is [hugo-theme-learn](https://themes.gohugo.io/hugo-theme-learn/). To start a new site in the current folder, run:
41
+
For a Hugo static site, you can choose your specific theme after you create the source files. The theme we'll use in this tutorial is [hugo-theme-relearn](https://themes.gohugo.io/themes/hugo-theme-relearn/). To start a new site in the current folder, run:
42
42
43
43
```
44
44
$ hugo new site docs-as-code
@@ -48,95 +48,103 @@ For a Hugo static site, you can choose your specific theme after you create the
48
48
1. Take a look at the files created in the directory with an `ls` command:
49
49
```
50
50
$ ls -A
51
-
archetypes content layouts themes
52
-
config.toml data static
51
+
archetypes content hugo.toml layouts themes
52
+
assets data i18n static
53
53
```
54
54
55
55
1. Initialize the current directory as a Git repository, which will enable you to bring the theme in as a Git submodule.
56
56
```
57
57
$ git init
58
-
Initialized empty Git repository in /Users/annegentle/src/src/hugo-example/.git/
58
+
Initialized empty Git repository in /Users/agentle/src/hugo-example/.git/
59
59
```
60
60
61
-
1. Edit `config.toml` in any text editor you like to get started. Choose a title for your site and the theme, in our case, `hugo-theme-learn`. The theme name in your configuration file must match the name of the specific theme directory inside the `/themes` directory, so we will add those files in the next step.
61
+
1. Edit `hugo.toml` in any text editor you like to get started. Choose a title for your site and the theme, in our case, `hugo-theme-relearn`. (Find the [installation documentation for the Relearn Theme here](https://mcshelby.github.io/hugo-theme-relearn/basics/installation/index.html).) The theme name in your configuration file must match the name of the specific theme directory inside the `/themes` directory, so we will add those files in the next step.
62
62
```
63
63
baseURL = "http://example.org/"
64
64
languageCode = "en-us"
65
65
title = "Learning Hugo Site"
66
-
theme = "hugo-theme-learn"
66
+
[module]
67
+
[[module.imports]]
68
+
path = 'github.com/McShelby/hugo-theme-relearn'
67
69
```
68
70
1. To get the theme files in the `/themes` directory, and keep them updated, use a `git submodules` command to get the required theme files as well as keep them updated.
1. For Hugo, the `content` folder contains the site source content. For your home page, make an `_index.md` document in the `content` folder and write it with Markdown content. Switch back up one level since you just cloned the theme files.
73
85
```
74
86
$ cd ..
75
-
$ hugo new _index.md
87
+
$ hugo new --kind home _index.md
88
+
Content "/Users/agentle/src/hugo-example/hugo-example/content/_index.md" created
76
89
```
77
-
1. Next, add a new page using the `hugo` command, `hugo new`:
90
+
1. Next, add a new chapter page using the `hugo` command, `hugo new`:
78
91
```
79
-
$ hugo new prerequisites.md
80
-
/Users/agentle/src/hugo-example/doc-machine/content/prerequisites.md created
92
+
$ hugo new --kind chapter get-started/_index.md
93
+
/Users/agentle/src/hugo-example/content/get-started/_index.md created
81
94
```
82
-
1. You can keep adding files with the `hugo new` command so that the Markdown files are pre-populated with the front matter:
95
+
1. You can keep adding files with the `hugo new` command so that the Markdown files are pre-populated with the front matter such as:
83
96
```
84
-
---
85
-
title: "Prerequisites"
86
-
date: 2018-06-16T10:38:19-05:00
87
-
draft: true
88
-
---
97
+
+++
98
+
archetype = "chapter"
99
+
title = "Get Started"
100
+
weight = 1
101
+
+++
89
102
```
90
103
91
104
## Build a Hugo site locally
92
105
93
106
Once you've prepared your local system, you can build locally and review the site in your browser.
94
107
95
-
For Hugo, it's important to know that draft pages are only served when using the `-D` parameter.
108
+
For Hugo, it's important to know that draft pages, where `draft = true` is in the front matter, won't be served.
96
109
97
-
1. Run the `hugo server`command with the `-D` parameter (to serve draft pages).
110
+
1. Run the `hugo server`(or `hugo serve`) command to run a local server with your draft website.
98
111
99
112
```
100
-
$ hugo server -D
101
-
102
-
| EN
103
-
+------------------+----+
104
-
Pages | 12
105
-
Paginator pages | 0
106
-
Non-page files | 0
107
-
Static files | 67
108
-
Processed images | 0
109
-
Aliases | 0
110
-
Sitemaps | 1
111
-
Cleaned | 0
112
-
113
-
Total in 48 ms
114
-
Watching for changes in /Users/agentle/src/hugo-example/doc-machine/{content,data,layouts,static,themes}
115
-
Watching for config changes in /Users/agentle/src/hugo-example/doc-machine/config.toml
116
-
Serving pages from memory
117
-
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
118
-
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
119
-
Press Ctrl+C to stop
113
+
$ hugo server
114
+
115
+
Watching for changes in /Users/agentle/src/hugo-learn/{archetypes,assets,content,data,i18n,layouts,static,themes}
116
+
Watching for config changes in /Users/agentle/src/hugo-learn/hugo.toml, /Users/agentle/src/hugo-learn/themes/hugo-theme-relearn/hugo.toml, /Users/agentle/src/hugo-learn/go.mod
117
+
Start building sites …
118
+
hugo v0.135.0+extended darwin/amd64 BuildDate=2024-09-27T13:17:08Z VendorInfo=brew
119
+
120
+
WARN deprecated: .Sites.First was deprecated in Hugo v0.127.0 and will be removed in a future release. Use .Sites.Default instead.
121
+
WARN deprecated: .Site.IsMultiLingual was deprecated in Hugo v0.124.0 and will be removed in a future release. Use hugo.IsMultilingual instead.
122
+
123
+
| EN
124
+
-------------------+------
125
+
Pages | 11
126
+
Paginator pages | 0
127
+
Non-page files | 0
128
+
Static files | 182
129
+
Processed images | 0
130
+
Aliases | 0
131
+
Cleaned | 0
132
+
133
+
Built in 276 ms
134
+
Environment: "development"
135
+
Serving pages from disk
136
+
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
137
+
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
138
+
Press Ctrl+C to stop
120
139
```
121
-
2. Open the **Web Server** URL, `http://localhost:1313/` in your local browser to view the site. (By default, the theme may be purple instead of green.)
140
+
2. Open the **Web Server** URL, `http://localhost:1313/` in your local browser to view the site.
122
141

123
142
3. Press `Ctrl+C` in the server terminal to stop the Hugo server.
124
143
4. You can add your files to a Git commit. Refer to [Working with content in GitHub repositories](https://docslikecode.com/learn/04-add-content-workflow/) for a documentation workflow with your Hugo site.
125
144
126
145
## Modify the Hugo theme
127
146
128
-
By default, the Hugo Theme "Learn" has a purple sidebar. How about changing the color and logo displayed in the sidebar? Here's how. While we're at it, let's make sure to configure the search tool that works best with this theme.
129
-
130
-
1. Edit the `config.toml` file and add these lines to the `config.toml` file. This example shows setting the `themeVariant` to `green`.
131
-
```
132
-
[params]
133
-
themeVariant = "green"
134
-
```
135
-
1. You can make sure that the theme works with the `lunr.js`[JavaScript search engine](https://lunrjs.com/) by adding these lines to the `config.toml` file.
136
-
```
137
-
[outputs]
138
-
home = [ "HTML", "RSS", "JSON"]
139
-
```
147
+
The Hugo Theme "Relearn" has many ways to [customize the theme](https://mcshelby.github.io/hugo-theme-relearn/basics/customization/index.html), including activating print support and a dedicated search page. Refer to the [Relearn theme documentation](https://mcshelby.github.io/hugo-theme-relearn/) for details.
140
148
141
149
## What's next
142
150
@@ -152,5 +160,5 @@ home = [ "HTML", "RSS", "JSON"]
0 commit comments