2021-08-25 11:33:29 +00:00
+++
2023-05-19 07:54:14 +00:00
tags = ["documentation"]
2021-08-25 11:33:29 +00:00
title = "Installation"
weight = 15
+++
2017-08-16 22:57:44 +00:00
2018-05-27 22:40:01 +00:00
The following steps are here to help you initialize your new website. If you don't know Hugo at all, we strongly suggest you learn more about it by following this [great documentation for beginners ](https://gohugo.io/overview/quickstart/ ).
2017-08-16 22:57:44 +00:00
2024-03-15 19:59:59 +00:00
{{% notice tip %}}
2024-04-12 15:30:16 +00:00
The following tutorial leads you through the steps of creating a first, minimal new site.
2024-03-15 19:59:59 +00:00
You don't need to edit any files besides your `hugo.toml` and only need to execute the commands in the given order.
{{% /notice %}}
2024-04-22 19:12:53 +00:00
## Create your Project
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
Hugo provides the `new` command to create a new website:
2024-03-15 19:59:59 +00:00
````shell
hugo new site my-new-site
````
After that change into the directory:
````shell
cd my-new-site
````
2017-08-16 22:57:44 +00:00
2024-03-15 19:59:59 +00:00
Every upcoming command will be executed from inside your new site's root.
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
## Install the Theme
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
### Downloading as Archive
2024-03-15 19:59:59 +00:00
2024-04-22 19:12:53 +00:00
You can [download the theme as .zip archive ](https://github.com/McShelby/hugo-theme-relearn/archive/main.zip ) and extract its content into them `themes/hugo-theme-relearn` directory.
2024-03-15 19:59:59 +00:00
2024-04-22 19:12:53 +00:00
Afterwards add this at the end of your `hugo.toml` .
2024-03-15 19:59:59 +00:00
2024-04-22 19:12:53 +00:00
{{< multiconfig file = hugo > }}
theme = "hugo-theme-relearn"
{{< / multiconfig > }}
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
### Using Hugo's Module System
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
You can install the Relearn theme by following [the standard documentation ](https://gohugo.io/hugo-modules/use-modules/#use-a-module-for-a-theme ) using Hugo's module system:
````shell
hugo mod init example.com
````
2023-02-05 12:01:49 +00:00
2024-04-22 19:12:53 +00:00
Afterwards add this at the end of your `hugo.toml` .
2023-02-05 12:01:49 +00:00
2024-04-22 19:12:53 +00:00
{{< multiconfig file = hugo > }}
[module]
[[module.imports]]
path = 'github.com/McShelby/hugo-theme-relearn'
{{< / multiconfig > }}
2023-02-05 12:01:49 +00:00
2024-04-22 19:12:53 +00:00
### Using Git Submodules
2023-02-05 12:01:49 +00:00
2024-04-22 19:12:53 +00:00
If you plan to store your project in a git repository you can create one with:
2023-02-05 12:01:49 +00:00
2024-04-22 19:12:53 +00:00
````shell
git init
````
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
Now add the theme as a submodule by:
````shell
git submodule add https://github.com/McShelby/hugo-theme-relearn.git themes/hugo-theme-relearn
````
Afterwards add this at the end of your `hugo.toml` .
2017-08-16 22:57:44 +00:00
2024-03-02 10:04:52 +00:00
{{< multiconfig file = hugo > }}
2021-06-30 12:56:06 +00:00
theme = "hugo-theme-relearn"
2024-03-02 10:04:52 +00:00
{{< / multiconfig > }}
2017-08-16 22:57:44 +00:00
2024-03-15 19:59:59 +00:00
## Create your Home Page
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
If you don't create a home page, yet, the theme will generate a placeholder text with instructions on how to proceed.
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
Start your journey by creating a home page:
2024-03-15 19:59:59 +00:00
````shell
hugo new --kind home _index.md
````
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
The newly created home page `content/_index.md` is empty and you obviously should add some meaningful content.
2024-03-15 19:59:59 +00:00
## Create your First Chapter Page
2024-04-22 19:12:53 +00:00
Chapters are meant to be top level pages that contain other child pages. They have a special layout style and often just contain the _title_ and a _brief abstract_ of the section.
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
Now create your first chapter page with the following command:
2017-08-16 22:57:44 +00:00
2024-03-02 10:04:52 +00:00
````shell
2017-08-16 22:57:44 +00:00
hugo new --kind chapter basics/_index.md
2024-03-02 10:04:52 +00:00
````
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
When opening the newly created file `content/basics/_index.md` , you should see the `weight` frontmatter with a number. This will be used to generate the subtitle of the chapter page, and should be set to a consecutive value starting at `1` for each chapter level.
2017-09-27 14:39:42 +00:00
2024-03-15 19:59:59 +00:00
## Create your First Content Pages
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
Then create content pages inside the previously created chapter. Here are three ways to create content in the chapter:
2017-08-16 22:57:44 +00:00
2024-03-02 10:04:52 +00:00
````shell
2024-04-22 19:12:53 +00:00
hugo new basics/first-content/_index.md
hugo new basics/second-content/index.md
hugo new basics/third-content.md
2024-03-02 10:04:52 +00:00
````
2017-08-16 22:57:44 +00:00
2021-08-23 21:51:52 +00:00
Feel free to edit those files by adding some sample content and replacing the `title` value in the beginning of the files.
2017-08-16 22:57:44 +00:00
2024-04-22 19:34:11 +00:00
{{% notice note %}}
2024-04-22 19:12:53 +00:00
Please note that Hugo overrides the default archetype template coming with this theme when using `hugo new site my-new-site` . To actually see your page later, you have to remove the `draft=true` from the page's frontmatter.
{{% /notice %}}
## Testing your Website Locally
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
Launch your new web site by using the following command:
2017-08-16 22:57:44 +00:00
2024-03-02 10:04:52 +00:00
````shell
2017-08-16 22:57:44 +00:00
hugo serve
2024-03-02 10:04:52 +00:00
````
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
Go to [`http://localhost:1313` ](http://localhost:1313 ) in your browser.
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
You should notice a few things:
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
1. The home page contains your provided text.
2. You have the menu **Basics** in the sidebar. Clicking on it reveals three submenus with names equal to the `title` properties in the previously created content pages.
3. While you are running `hugo serve` your page refreshes automatically when you change a content page. Neat!
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
## Build and Deploy your Website
2017-08-16 22:57:44 +00:00
2024-04-22 19:29:10 +00:00
When your site is ready to be deployed, run the following command:
2017-08-16 22:57:44 +00:00
2024-03-02 10:04:52 +00:00
````shell
2017-08-16 22:57:44 +00:00
hugo
2024-03-02 10:04:52 +00:00
````
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
A `public` directory will be generated, containing all content and assets for your web site.
2017-08-16 22:57:44 +00:00
2024-04-22 19:12:53 +00:00
It now can be deployed to any web server by simply uploading its contents or you can check out one of [Hugo's many other deployment options ](https://gohugo.io/hosting-and-deployment/ ).
2024-04-22 19:29:10 +00:00
2024-04-22 19:34:11 +00:00
{{% notice note %}}
2024-04-22 19:29:10 +00:00
If you are storing your web site in git, commit all but the `public` directory.
2024-04-22 19:34:11 +00:00
{{% /notice %}}