2023-08-16 17:33:39 +01:00
---
title: Getting Started
weight: 1
2023-08-20 19:20:24 +01:00
next: /docs/guide
2023-08-22 00:48:44 +01:00
prev: /docs
2023-08-16 17:33:39 +01:00
---
2023-08-26 15:36:46 +01:00
## Quick Start from Template
2023-08-28 22:32:50 +01:00
{{< icon " github " > }} [imfing/hextra-starter-template ](https://github.com/imfing/hextra-starter-template )
2023-08-26 15:36:46 +01:00
2023-10-27 18:15:06 -04:00
You could quickly get started by using the above template repository.
2023-08-26 15:36:46 +01:00
< img src = "https://docs.github.com/assets/cb-77734/mw-1440/images/help/repository/use-this-template-button.webp" width = "500" >
We have provided a [GitHub Actions workflow ](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow ) which can help automatically build and deploy your site to GitHub Pages, and host it for free.
2023-10-27 18:09:38 -04:00
For more options, check out [Deploy Site ](../guide/deploy-site ).
2023-08-26 15:36:46 +01:00
[🌐 Demo ↗ ](https://imfing.github.io/hextra-starter-template/ )
2023-08-16 17:33:39 +01:00
## Start as New Project
2023-10-27 18:15:06 -04:00
There are two main ways to add the Hextra theme to your Hugo project:
2023-08-19 13:42:59 +01:00
2023-10-16 18:58:28 +05:30
1. **Hugo Modules (Recommended)** : The simplest and recommended method. [Hugo modules ](https://gohugo.io/hugo-modules/ ) let you pull in the theme directly from its online source. Theme is downloaded automatically and managed by Hugo.
2023-08-16 17:33:39 +01:00
2023-10-27 18:15:06 -04:00
2. **Git Submodule** : Alternatively, add Hextra as a [Git Submodule ](https://git-scm.com/book/en/v2/Git-Tools-Submodules ). The theme is downloaded by Git and stored in your project's `themes` folder.
2023-10-16 18:58:28 +05:30
### Setup Hextra as Hugo module
#### Prerequisites
2023-10-27 18:15:06 -04:00
Before starting, you need to have the following software installed:
2023-10-16 18:58:28 +05:30
- [Hugo (extended version) ](https://gohugo.io/installation/ )
- [Git ](https://git-scm.com/ )
- [Go ](https://go.dev/ )
#### Steps
2023-08-19 13:42:59 +01:00
2023-08-16 17:33:39 +01:00
{{% steps %}}
### Initialize a new Hugo site
2023-10-16 18:58:28 +05:30
```shell
2023-11-11 20:14:39 -05:00
hugo new site my-site --format=yaml
2023-08-16 17:33:39 +01:00
```
2023-08-19 13:42:59 +01:00
### Configure Hextra theme via module
2023-08-16 17:33:39 +01:00
```shell
# initialize hugo module
2023-11-11 20:14:39 -05:00
cd my-site
hugo mod init github.com/username/my-site
2023-08-16 17:33:39 +01:00
# add Hextra theme
2023-11-11 20:14:39 -05:00
hugo mod get github.com/imfing/hextra
2023-08-16 17:33:39 +01:00
```
2023-10-16 18:58:28 +05:30
Configure `hugo.yaml` to use Hextra theme by adding the following:
2023-08-16 17:33:39 +01:00
```yaml
module:
imports:
- path: github.com/imfing/hextra
```
2023-08-19 13:42:59 +01:00
### Create your first content pages
2023-10-27 18:15:06 -04:00
Create new content page for the home page and the documentation page:
2023-08-19 13:42:59 +01:00
```shell
2023-11-11 20:14:39 -05:00
hugo new content/_index.md
hugo new content/docs/_index.md
2023-08-19 13:42:59 +01:00
```
### Preview the site locally
2023-08-16 17:33:39 +01:00
```shell
2023-11-11 20:14:39 -05:00
hugo server --buildDrafts --disableFastRender
2023-08-16 17:33:39 +01:00
```
2023-10-27 18:15:06 -04:00
Voila, your new site preview is available at `http://localhost:1313/` .
2023-08-16 17:33:39 +01:00
{{% /steps %}}
2023-08-19 13:42:59 +01:00
2023-09-02 16:02:21 +01:00
{{% details title="How to update theme?" %}}
2023-10-16 18:58:28 +05:30
To update all Hugo modules in your project to their latest versions, run the following command:
2023-09-02 16:02:21 +01:00
```shell
2023-11-11 20:14:39 -05:00
hugo mod get -u
2023-09-02 16:02:21 +01:00
```
2023-10-27 18:15:06 -04:00
To update Hextra to the [latest released version ](https://github.com/imfing/hextra/releases ), run the following command:
2023-10-16 18:58:28 +05:30
```shell
hugo mod get -u github.com/imfing/hextra
```
2023-09-02 16:02:21 +01:00
See [Hugo Modules ](https://gohugo.io/hugo-modules/use-modules/#update-all-modules ) for more details.
{{% /details %}}
2023-10-16 18:58:28 +05:30
### Setup Hextra as Git submodule
#### Prerequisites
2023-10-27 18:15:06 -04:00
Before starting, you need to have the following software installed:
2023-10-16 18:58:28 +05:30
- [Hugo (extended version) ](https://gohugo.io/installation/ )
- [Git ](https://git-scm.com/ )
#### Steps
{{% steps %}}
### Initialize a new Hugo site
```shell
2023-11-11 20:14:39 -05:00
hugo new site my-site --format=yaml
2023-10-16 18:58:28 +05:30
```
### Add Hextra theme as a Git submodule
```shell
git submodule add https://github.com/imfing/hextra.git themes/hextra
```
Configure `hugo.yaml` to use Hextra theme by adding the following:
```yaml
theme: hextra
```
### Create your first content pages
2023-10-27 18:15:06 -04:00
Create new content page for the home page and the documentation page:
2023-10-16 18:58:28 +05:30
```shell
2023-11-11 20:14:39 -05:00
hugo new content/_index.md
hugo new content/docs/_index.md
2023-10-16 18:58:28 +05:30
```
### Preview the site locally
```shell
2023-11-11 20:14:39 -05:00
hugo server --buildDrafts --disableFastRender
2023-10-16 18:58:28 +05:30
```
2023-10-27 18:15:06 -04:00
Your new site preview is available at `http://localhost:1313/` .
2023-10-16 18:58:28 +05:30
{{% /steps %}}
When using [CI/CD ](https://en.wikipedia.org/wiki/CI/CD ) for Hugo website deployment, it's essential to ensure that the following command is executed before running the `hugo` command.
```shell
git submodule update --init
```
2023-10-27 18:15:06 -04:00
Failure to run this command results in the theme folder not being populated with Hextra theme files, leading to a build failure.
2023-10-16 18:58:28 +05:30
{{% details title="How to update theme?" %}}
To update all submodules in your repository to their latest commits, run the following command:
```shell
2023-11-11 20:14:39 -05:00
git submodule update --remote
2023-10-16 18:58:28 +05:30
```
2023-10-27 18:15:06 -04:00
To update Hextra to the latest commit, run the following command:
2023-10-16 18:58:28 +05:30
```shell
git submodule update --remote themes/hextra
```
See [Git submodules ](https://git-scm.com/book/en/v2/Git-Tools-Submodules ) for more details.
{{% /details %}}
2023-09-02 16:02:21 +01:00
2023-08-19 13:42:59 +01:00
## Next
Explore the following sections to start adding more contents:
{{< cards > }}
2023-08-26 15:01:06 +01:00
{{< card link = "../guide/organize-files" title = "Organize Files" icon = "document-duplicate" > }}
{{< card link = "../guide/configuration" title = "Configuration" icon = "adjustments" > }}
{{< card link = "../guide/markdown" title = "Markdown" icon = "markdown" > }}
2023-08-19 13:42:59 +01:00
{{< / cards > }}