These pages apply to Docsy v0.16.0 and compatible versions, and
target release refers to the Docsy version that you are updating your site
to. For what changed in a given release, and any release-specific upgrade
actions, see the upgrade blog posts.
Before you begin
Backup or safeguard your project’s current state: for example, work from a
Git branch, merging only after checking your site, or back up your
project files first. Rolling back is then a simple restore.
Updating from Docsy 0.15 or earlier? First apply the
theme-path config changes, and only those, from the 0.16.0 post’s theme
folder actions; this page’s steps cover the rest.
Order of steps
Perform the update steps in the order given by this page:
Node.js and Hugo, when your target release
calls for it
Applies if your target release names a newer Node.js version than your
project uses; its upgrade blog post says so. With nvm,
install and select that version, for example:
nvm install NODE_VERSION
Replace NODE_VERSION with the version that the upgrade post names.
Update Hugo
Applies if your target release raises the minimum or recommended Hugo
version; its upgrade blog post says so. For projects using the
hugo-extended NPM package, update the package version, for
example:
The remaining update steps apply to all install modes.
Review your theme overrides
If your project overrides theme files, then after updating,
diff each override against its new theme counterpart and port upstream changes
as needed. Look for overrides in your project’s:
assets/
i18n/
layouts/, the most common location
static/
Docsy’s project style files (_variables_project.scss and
friends) also work this way, but the theme’s copies are placeholders that are
intentionally empty: there’s nothing to diff, so they don’t need this review.
Check your site
After updating, build or serve your site and check for errors and warnings. We
recommend building both development and production versions of your site, since
they can differ in their configuration, minification, etc.
Use this checklist as a guide to verify that your update succeeded:
Build completes without warnings or deprecation notices
Key pages load and have proper layout, for example the site home, a doc
page, and a blog post. On each page:
Browser console shows no errors
Nav links resolve; breadcrumbs show current path; current section is
highlighted
External links show expected styling (for example, icon)
On mobile or tablet: navigation is usable and there is no horizontal
scroll
Dark mode toggle works, if enabled
Custom shortcodes render correctly, if used
Search returns expected results, if used
Print preview looks correct, if used
Also perform any release-specific checks listed in the release’s
upgrade blog post.
1 - Update your Docsy Hugo Module
Update Docsy with hugo mod get, for sites that manage the theme as a Hugo Module.
At the command prompt, change to the root directory of your existing site.
cd /path/to/my-existing-site
Then invoke Hugo’s module get subcommand with the update flag:
hugo mod get -u github.com/google/docsy/theme
Hugo automatically pulls in the latest theme version.
Tip
To pin the theme to a specific version, specify its tag when updating, for
example:
hugo mod get github.com/google/docsy/theme@v0.16.0
Instead of a version tag, you can also specify a commit hash, for example:
hugo mod get github.com/google/docsy/theme@9b1d9951
After updating the theme, tidy your module files, refresh the theme npm
dependencies that are consolidated into your site’s package.json, and
reinstall them:
hugo mod tidy
hugo mod npm pack
npm install
Hugo warns at build time when your package.json dependency set has drifted
from the theme’s. To verify the resolved version, run:
hugo mod graph
Confirm that it lists github.com/google/docsy/theme at the version you expect.
After updating the theme, continue with the remaining update steps, starting
with Review your theme overrides.
2 - Update your Docsy NPM package
Update Docsy with npm install, for sites that use the @docsy/theme package.
Update the theme to the latest release by running the following from your
project root:
npm install --save-dev @docsy/theme@latest
Tip
To pin a specific version, name it explicitly, for example:
npm install --save-dev @docsy/theme@v0.16.0
To verify the resolved version of @docsy/theme, run:
npm ls @docsy/theme --depth=0
If your site installs Docsy from GitHub with npm (a mode reserved
for Docsy development and testing), update by re-running the install command
with the desired revision selector.
After updating the theme, continue with the remaining update steps, starting
with Review your theme overrides.
3 - Update your Docsy Git submodule or clone
Update a Docsy theme vendored under themes/ as a Git submodule or clone.
Use the procedure matching how Docsy was installed in your project:
submodule or clone.
Ensure that origin is set to https://github.com/google/docsy.git
(git -C themes/docsy remote -v).
Reinstall the theme’s runtime dependencies:
npm run postinstall --prefix themes/docsy
As in the submodule procedure, run npm run postinstall, not npm install.
Persist the update to your project, the same way that your project already
tracks the cloned theme: for example, commit the updated theme files to your
project repository, or record the new tag where your build restores the clone
from.
If you have local changes in the cloned theme, commit or stash them first:
checking out a tag fails on uncommitted changes, and detaches HEAD from any
local branch. After checking out the new tag, reapply your changes (for example,
git stash pop, or rebase your branch onto the tag), resolving any conflicts.
After updating the theme, continue with the remaining update steps, starting
with Review your theme overrides.
4 - Migrate to Hugo Modules
Move a submodule- or clone-based site to Hugo Modules and simplify future updates.
TL;DR: Conversion for the impatient expert
Run the following from the command line:
cd /path/to/my-existing-site
hugo mod init github.com/me-at-github/my-existing-site
hugo mod get github.com/google/docsy/theme@v0.16.0
sed -i '/theme = \["docsy/d' config.toml
mv config.toml hugo.toml
cat >> hugo.toml <<EOL
[module]
proxy = "direct"
[[module.imports]]
path = "github.com/google/docsy/theme"
EOLhugo mod npm pack
npm install
hugo server
cd my-existing-site
hugo mod init github.com/me-at-github/my-existing-site
hugo mod get github.com/google/docsy/theme@v0.16.0
findstr /v /c:"theme = [\"docsy" config.toml > hugo.toml(echo [module]^
proxy = "direct"^
[[module.imports]]^
path = "github.com/google/docsy/theme")>>hugo.toml
hugo mod npm pack
npm install
hugo server
Detailed conversion instructions
Import the Docsy theme module as a dependency of your site
At the command prompt, change to the root directory of your existing site.
cd /path/to/my-existing-site
Only sites that are Hugo Modules themselves can import other Hugo Modules. Turn your existing site into a Hugo Module by running the following command from your site directory, replacing github.com/me/my-existing-site with your site repository:
hugo mod init github.com/me/my-existing-site
This creates two new files, go.mod for the module definitions and go.sum which holds the checksums for module verification.
Next declare the Docsy theme module as a dependency for your site.
hugo mod get github.com/google/docsy/theme@v0.16.0
This command adds the docsy theme module to your definition file go.mod.
Update your config file
In your hugo.toml/hugo.yaml/hugo.json file, update the theme setting to use Hugo Modules. Find the following line (docsy/theme if your site is on Docsy 0.16 or later, docsy otherwise):
theme=["docsy/theme"]
theme:docsy/theme
"theme":"docsy/theme"
Change this line to:
theme=["github.com/google/docsy/theme"]
theme:- github.com/google/docsy/theme
"theme":["github.com/google/docsy/theme"]
Alternatively, you can omit this line altogether and replace it with the settings given in the following snippet:
[module]proxy="direct"# uncomment line below for temporary local development of module# replacements = "github.com/google/docsy/theme -> ../../docsy/theme"[module.hugoVersion]extended=truemin=0.160.1[[module.imports]]path="github.com/google/docsy/theme"disable=false
You can find details of what these configuration settings do in the Hugo modules documentation.
Depending on your environment you may need to tweak them slightly, for example by adding a proxy to use when downloading remote modules.
Tip
In Hugo 0.110.0 the default config base filename was changed to hugo.toml.
If you are using hugo 0.110 or above, we recommend renaming your config.toml
to hugo.toml!
Caution
If you have a multi-language installation, make sure that the section
[languages] inside your hugo.toml is declared before the section
[module] with the module imports. Otherwise you will run into trouble!
Install theme npm dependencies
Docsy sources its Bootstrap and Font Awesome assets from npm. Consolidate the
theme’s npm dependencies into your project’s package.json and install them:
To make sure that your configuration settings are correct, run 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/google/docsy/theme@v0.16.0
Make sure that the docsy/theme dependency is listed. If not, please double check your config settings.
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/google/docsy/theme"
Clean up your repository
Since your site now uses Hugo Modules, you can remove docsy from the themes directory, as instructed below.
First, change to the root directory of your site:
cd /path/to/my-existing-site
Previous use of Docsy theme as git clone
Simply remove the subdirectory docsy inside your themes directory:
rm -rf themes/docsy
Previous use of Docsy theme as git submodule
If your Docsy theme was installed as submodule, use git’s rm subcommand to remove the subdirectory docsy inside your themes directory:
git rm -rf themes/docsy
You are now ready to commit your changes to your repository:
git commit -m "Removed docsy git submodule"
Caution
Be careful when using the rm -rf command, make sure that you don’t
inadvertently delete any productive data files!