Skip to content

Commit

Permalink
Docu for conversion of existing site: improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
deining committed Jan 17, 2022
1 parent 191888e commit cfbca8f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ hugo mod get github.com/google/docsy

[[module.imports]]^

path = "github.com/google/docsy")>config.toml
path = "github.com/google/docsy")>>config.toml
md assets\vendor\bootstrap\scss\vendor
cd assets\vendor\bootstrap\scss\vendor
REM Windows 10 only
curl.exe -O --url https://raw.githubusercontent.com/twbs/bootstrap/v4.6.1/scss/vendor/_rfs.scss
cd ..\..\..\..
cd ..\..\..\..\..
hugo server
{{< /tab >}}
{{< /tabpane >}}
Expand All @@ -66,7 +66,7 @@ cd my-new-site

This will create a minimal site structure, containing the folders `archetypes`, `content`, `data`, `layouts`, `static`, and `themes` and a configuration file, `config.toml.

### Add the Docsy theme module to your site
### Import the Docsy theme module as a dependency of your site

Only sites that are hugo modules themselves can import other hugo modules. So turn your site into a Hugo Module by executing the following commands from within your newly created site directory:

Expand Down
48 changes: 41 additions & 7 deletions userguide/content/en/docs/Updating/Convert-site-to-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ At your command prompt, issue:
cd /path/to/my-existing-site
hugo mod init github.com/me-at-github/my-existing-site
hugo mod get github.com/google/docsy
sed -i '/theme = \["docsy"\]/d' config.toml
cat >> config.toml <<EOL
[module]
[[module.imports]]
Expand All @@ -28,24 +29,26 @@ hugo server
cd my-existing-site
hugo mod init github.com/me-at-github/my-existing-site
hugo mod get github.com/google/docsy
findstr /v /c:"theme = [\"docsy\"]" config.toml > config.toml.temp
move /Y config.toml.temp config.toml
(echo [module]^

[[module.imports]]^

path = "github.com/google/docsy"^)>config.toml
path = "github.com/google/docsy"^)>>config.toml
md assets\vendor\bootstrap\scss\vendor
cd assets\vendor\bootstrap\scss\vendor
REM Windows 10 only
curl.exe -O --url https://raw.githubusercontent.com/twbs/bootstrap/v4.6.1/scss/vendor/_rfs.scss
cd ..\..\..\..
cd ..\..\..\..\..
hugo server
{{< /tab >}}
{{< /tabpane >}}


## Detailed Setup instructions
## Detailed Conversion instructions

### Add the Docsy theme module to your site
### Import the Docsy theme module as a dependency of your site

At the command prompt, change to the root directory of your existing site.

Expand All @@ -69,9 +72,15 @@ hugo mod get github.com/google/docsy

This will add the docsy theme module to your definition file `go.mod`.

### Add theme module configuration settings
### Alter the docsy theme definition from local install to Hugo module

Next, add the settings given in the code box below at the end of your site configuration file (default: `config.toml`).
Inside your `config.toml, identify the following line:

```
theme = ["docsy"]
```

Remove this line and replace it with the settings given in the code box below:

{{< tabpane >}}
{{< tab header="config.toml" >}}
Expand Down Expand Up @@ -112,6 +121,31 @@ module:
{{< /tab >}}
{{< /tabpane >}}

### Check validity of your configuration settings

To make sure that your configuration settings are correct, issue the command `hugo mod graph` which prints a module dependency graph:

```
hugo mod graph
hugo: collected modules in 1092 ms
github.com/me/my-existing-site github.com/deining/docsy@v0.0.0-20220114173756-13dd72fd59ba
github.com/google/docsy@v0.0.0-20220114173756-13dd72fd59ba github.com/twbs/bootstrap@v4.6.1+incompatible
github.com/google/docsy@v0.0.0-20220114173756-13dd72fd59ba github.com/FortAwesome/Font-Awesome@v0.0.0-20210804190922-7d3d774145ac
```

Make sure that three lines with dependencies `docsy`, `bootstrap` and `Font-Awesome` are listed. If not, please double check your config settings.

{{% alert title="Tip" %}}
In order to clean up your module cache, issue the command `hugo mod clean`

```
hugo mod clean
hugo: collected modules in 995 ms
hugo: cleaned module cache for "github.com/FortAwesome/Font-Awesome"
hugo: cleaned module cache for "github.com/google/docsy"
hugo: cleaned module cache for "github.com/twbs/bootstrap"
```
{{% /alert %}}

### Work around a known bug in Go's module management

Expand Down Expand Up @@ -151,7 +185,7 @@ wget -P assets/vendor/bootstrap/scss/vendor https://raw.githubusercontent.com/tw

### Remove theme and submodule incl. leftovers

Since your site makes now use of hugo modules, your previous used themes directory can be removed:
Since your site makes now use of hugo modules, your previously used `themes` directory can be removed:

```
rm -rf /path/to/your/theme
Expand Down

0 comments on commit cfbca8f

Please sign in to comment.