forked from drowl87/hextra_mirror
docs: add using Hextra as Git submodule (#137)
* docs: update docs relating to getting started and Hugo modules * docs: add docs to use Hextra as Git submodule, closes #107 * chore: use paragraph instead of callout, refactor docs * Update getting-started.md * Update getting-started.md --------- Co-authored-by: Xin <xin@imfing.com>
This commit is contained in:
parent
e42d01898a
commit
6641d36b98
@ -19,18 +19,29 @@ We have provided a [GitHub Actions workflow](https://docs.github.com/en/pages/ge
|
|||||||
|
|
||||||
## Start as New Project
|
## Start as New Project
|
||||||
|
|
||||||
### Prerequisites
|
There are two main ways to add the Hextra theme to your Hugo project.
|
||||||
|
|
||||||
Before we start, make sure we have [Hugo](https://gohugo.io/) installed.
|
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.
|
||||||
Please refer to Hugo's [official installation guide](https://gohugo.io/installation/) for more details.
|
|
||||||
|
|
||||||
[Hugo modules](https://gohugo.io/hugo-modules/) are the recommended way to manage Hugo themes. To use Hugo modules, we need to install [Git](https://git-scm.com/) and [Go](https://go.dev/).
|
2. **Git Submodule**: Alternatively, add Hextra as a [Git Submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules). The theme will be downloaded by Git and stored in your project's `themes` folder.
|
||||||
|
|
||||||
|
### Setup Hextra as Hugo module
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
|
||||||
|
Before starting, you need to have the following softwares installed:
|
||||||
|
|
||||||
|
- [Hugo (extended version)](https://gohugo.io/installation/)
|
||||||
|
- [Git](https://git-scm.com/)
|
||||||
|
- [Go](https://go.dev/)
|
||||||
|
|
||||||
|
#### Steps
|
||||||
|
|
||||||
{{% steps %}}
|
{{% steps %}}
|
||||||
|
|
||||||
### Initialize a new Hugo site
|
### Initialize a new Hugo site
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
$ hugo new site my-site --format=yaml
|
$ hugo new site my-site --format=yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -45,7 +56,7 @@ $ hugo mod init github.com/username/my-site
|
|||||||
$ hugo mod get github.com/imfing/hextra
|
$ hugo mod get github.com/imfing/hextra
|
||||||
```
|
```
|
||||||
|
|
||||||
Edit `hugo.yaml` to enable Hextra theme:
|
Configure `hugo.yaml` to use Hextra theme by adding the following:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
module:
|
module:
|
||||||
@ -55,7 +66,7 @@ module:
|
|||||||
|
|
||||||
### Create your first content pages
|
### Create your first content pages
|
||||||
|
|
||||||
Let's create a new content page for the home page and the documentation page:
|
Let's create new content page for the home page and the documentation page:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ hugo new content/_index.md
|
$ hugo new content/_index.md
|
||||||
@ -73,20 +84,101 @@ Voila! You can see your new site at `http://localhost:1313/`.
|
|||||||
{{% /steps %}}
|
{{% /steps %}}
|
||||||
|
|
||||||
|
|
||||||
## Update Theme
|
|
||||||
|
|
||||||
{{% details title="How to update theme?" %}}
|
{{% details title="How to update theme?" %}}
|
||||||
|
|
||||||
To update the theme to the [latest released version](https://github.com/imfing/hextra/releases), run the following command:
|
To update all Hugo modules in your project to their latest versions, run the following command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ hugo mod get -u
|
$ hugo mod get -u
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To update only Hextra to the [latest released version](https://github.com/imfing/hextra/releases), run the following command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
hugo mod get -u github.com/imfing/hextra
|
||||||
|
```
|
||||||
|
|
||||||
See [Hugo Modules](https://gohugo.io/hugo-modules/use-modules/#update-all-modules) for more details.
|
See [Hugo Modules](https://gohugo.io/hugo-modules/use-modules/#update-all-modules) for more details.
|
||||||
|
|
||||||
{{% /details %}}
|
{{% /details %}}
|
||||||
|
|
||||||
|
### Setup Hextra as Git submodule
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
|
||||||
|
Before starting, you need to have the following softwares installed:
|
||||||
|
|
||||||
|
- [Hugo (extended version)](https://gohugo.io/installation/)
|
||||||
|
- [Git](https://git-scm.com/)
|
||||||
|
|
||||||
|
#### Steps
|
||||||
|
|
||||||
|
{{% steps %}}
|
||||||
|
|
||||||
|
### Initialize a new Hugo site
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ hugo new site my-site --format=yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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
|
||||||
|
|
||||||
|
Let's create new content page for the home page and the documentation page:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ hugo new content/_index.md
|
||||||
|
$ hugo new content/docs/_index.md
|
||||||
|
```
|
||||||
|
|
||||||
|
### Preview the site locally
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ hugo server --buildDrafts --disableFastRender
|
||||||
|
```
|
||||||
|
|
||||||
|
Voila! You can see your new site at `http://localhost:1313/`.
|
||||||
|
|
||||||
|
{{% /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
|
||||||
|
```
|
||||||
|
|
||||||
|
Failure to run this command will result in the theme folder not being populated with Hextra theme files, leading to a build failure.
|
||||||
|
|
||||||
|
|
||||||
|
{{% details title="How to update theme?" %}}
|
||||||
|
|
||||||
|
To update all submodules in your repository to their latest commits, run the following command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ git submodule update --remote
|
||||||
|
```
|
||||||
|
|
||||||
|
To update only Hextra to the latest commit, run the following command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
git submodule update --remote themes/hextra
|
||||||
|
```
|
||||||
|
|
||||||
|
See [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) for more details.
|
||||||
|
|
||||||
|
{{% /details %}}
|
||||||
|
|
||||||
## Next
|
## Next
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user