Reuse directories of content with Hugo mounts
Note: The following task can only be performed by a Grafana Labs employee.
Before Hugo performs a build, Hugo mounts mount a source directory at a destination directory. Use Hugo mounts to reuse a whole directory of content in another part of the published technical documentation.
Before you begin
- Identify a directory of content that you want to reuse.
- Identify any pages to exclude.
Typically, excluded pages do not make sense in the context of the target directory.
Warning: Pages in the directory might have relative links to other pages that would be broken by their exclusion. If the excluded page is replaced by another in the target directory, relative links will continue to work. Otherwise, the broken relative links should be made absolute. That way, they will always refer to the page in the source directory.
To reuse a shared directory:
Determine the source and target directories.
The source directory is the path to a directory in the
websiterepository. It always has the path prefix
content/docs/. The source directory for all Grafana Cloud content at the URL https://grafana.com/docs/grafana-cloud/ is
Similarly, the target directory has the path prefix
content/docs. For the destination URL
https://grafana.com/docs/target-directory/, the path is
For every page in the source directory, set the canonical URL using the
canonicalfront matter, to the currently published open source page.
canonicalfront matter indicates the preferred URL for duplicate or very similar pages. For more information, refer to Canonical.
Update the website repository Hugo configuration.
The configuration is in the in the
websiterepository in the
Append the mount to the
docs.manual_mountkey in the YAML configuration.
For example, mount the source
content/docs/target-directoryand exclude the root
- source: content/docs/source-directory target: content/docs/target-directory excludeFiles: - /_index.md