These pages apply to Docsy v0.16.1-dev 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.
Updating from Docsy 0.16 or earlier? Before updating
the theme, provide the Dart Sass compiler in every environment that builds
your site; see the 0.17.0 post’s
Dart Sass actions.
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.
Astuce
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 generated theme
npm dependencies workspace, and reinstall it:
hugo mod tidy
hugo mod npm pack
npm install
Hugo warns at build time when the generated workspace’s 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
Astuce
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 install:theme-deps --prefix themes/docsy
As in the submodule procedure, run npm run install:theme-deps, 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:
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
[ -f config.toml ]&& mv config.toml hugo.toml
sed -i.bak '/theme = \["docsy/d' hugo.toml && rm hugo.toml.bak
cat >> hugo.toml <<EOL
[module]
proxy = "direct"
[[module.imports]]
path = "github.com/google/docsy/theme"
EOLnpm install --save-exact --save-dev sass-embedded@1.102.0
npm pkg set scripts.hugo=hugo
hugo mod npm pack
npm install
npm run 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
ifexist config.toml ren config.toml hugo.toml
findstr /v /c:"theme = [\"docsy" hugo.toml > hugo.toml.tmpmove /y hugo.toml.tmp hugo.toml
(echo [module]^
proxy = "direct"^
[[module.imports]]^
path = "github.com/google/docsy/theme")>>hugo.toml
npm install --save-exact --save-dev sass-embedded@1.102.0
npm pkg set scripts.hugo=hugo
hugo mod npm pack
npm install
npm run hugo -- server
Detailed conversion instructions
Import the Docsy theme module as a dependency of your site
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-at-github/my-existing-site with your site repository:
hugo mod init github.com/me-at-github/my-existing-site
This creates a go.mod file for your site’s module definitions.
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 and
records the module checksums in go.sum.
Update your config file
If your site still uses a config.toml file, rename it to hugo.toml first.
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.
Prudence
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
Follow Install Dart Sass so that Hugo runs with the sass
CLI on its PATH; for npm-based sites, that means installing the tested
sass-embedded version and running Hugo through npm scripts:
npm install --save-exact --save-dev sass-embedded@1.102.0
npm pkg set scripts.hugo=hugo
Docsy sources its Bootstrap and Font Awesome assets from npm. Generate the
theme’s npm-dependency workspace (see Hugo’s
Node dependencies) and
install it:
hugo mod npm pack
npm install
Re-run hugo mod npm pack whenever you
update Docsy or otherwise edit package.json;
Hugo warns when the dependency set drifts. For background, see
Bootstrap and Font Awesome via npm in the 0.16.0
release notes.
Check validity of your configuration settings
Run hugo mod graph and verify that it lists github.com/google/docsy/theme:
hugo mod graph
hugo: collected modules in 1092 ms
github.com/me-at-github/my-existing-site github.com/google/docsy/theme@v0.16.0
Astuce
To clear the module cache:
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, remove the docsy theme copy from your
project’s themes/ directory:
For a theme clone:
rm -rf themes/docsy
For a theme submodule:
git rm -rf themes/docsy
Then commit the change:
git commit -m "Removed docsy git submodule"
Prudence
Be careful when using the rm -rf command, make sure that you don’t
inadvertently delete any productive data files!