Skip to content

Commit

Permalink
Hacking docsy theme (using hugo workspace)
Browse files Browse the repository at this point in the history
  • Loading branch information
deining committed Dec 28, 2022
1 parent 2112cfb commit e97abca
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,37 @@ docker-compose rm
For more information see the [Docker Compose
documentation](https://docs.docker.com/compose/gettingstarted/).

## Hacking the docsy theme

This repo contains the docsy repo as git submodule (folder: `themes/docsy`), assure that this repo is checked out:

```shell
git submodule init
```

Make sure your installed hugo version is `v0.109.0` or higher:

```shell
hugo version
hugo v0.109.0-47b12b83e636224e5e601813ff3e6790c191e371+extended linux/amd64 BuildDate=2022-12-23T10:38:11Z VendorInfo=gohugoio
```

Now run:

```shell
HUGO_MODULE_WORKSPACE=hugo.work hugo server --ignoreVendorPaths "**"
```

By using the `HUGO_MODULE_WORKSPACE` directive, the server now watches all files and directories inside the `themes/docsy` directory, too. Any changes inside the local `docsy` theme clone are now immediately picked up (hot reload), you can instantly see the effect of your local edits.


In the command above, we used the environment variable `HUGO_MODULE_WORKSPACE` to tell hugo about the local workspace file `hugo.work`. As an alternative, you can declare the workspace file inside your settings file `config.toml`:

```toml
[module]
workspace = "hugo.work"
```

## Troubleshooting

As you run the website locally, you may run into the following error:
Expand Down
5 changes: 3 additions & 2 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ enable = false
# hugo module configuration

[module]
# uncomment line below for temporary local development of module
# replacements = "github.com/google/docsy -> ../../docsy"
# uncomment line below for local development of module
# needs hugo v0.109.0 or higher and go 1.18 or higher
# workspace = "hugo.work"
[module.hugoVersion]
extended = true
min = "0.75.0"
Expand Down
3 changes: 3 additions & 0 deletions hugo.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go 1.19

use ./themes/docsy/
2 changes: 2 additions & 0 deletions hugo.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/google/docsy/dependencies v0.6.0 h1:BFXDCINbp8ZuUGl/mrHjMfhCg+b1YX+hVLAA5fGW7Pc=
github.com/google/docsy/dependencies v0.6.0/go.mod h1:EDGc2znMbGUw0RW5kWwy2oGgLt0iVXBmoq4UOqstuNE=

0 comments on commit e97abca

Please sign in to comment.