Skip to content

Hugo docs: Support newer Hugo and Hugo Relearn versions; update README #6264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 72 additions & 29 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
# Quick start guide:
# Quick start guide

- Visit https://xapi-project.github.io/new-docs/ to view the current documentation.
- Visit <https://xapi-project.github.io/new-docs/> to view the current documentation.

## Required software

The docs use Hugo and the [Hugo Relearn theme](https://mcshelby.github.io/hugo-theme-relearn),
an enhanced fork of the popular Hugo Learn theme.

### Compatible versions
### Supported versions of Hugo and the Hugo Relearn theme

Due to a number of gradual changes in Hugo and Relearn,
the docs are currently only compatible with specific older versions of Hugo and Relearn.
Hugo Relearn 6.4.0 is currently used (defined by a git tag in `doc/go.mod`).

Hugo v0.121.0 to ~v0.127.0 (the current version of the Ubuntu `snap` is too recent)
- Fixes to support newer versions are forthcoming.

Hugo Relearn 5.24.0 (defined by a git tag in doc/go.mod)
- Note: Hugo Relearn >= 5.25 currently trigger additional warnings due to deprecations.
- Further updates fix this situation are forthcoming step by step.

Hugo Relearn >= 5.24.0 and < 6.x are expected to work:
- https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/5/index.html#5-24-0
- Breaking changes in Relearn 6.0.0:
https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/6/#6-0-0
- The minimum Hugo version required by the Relearn theme is 0.126.0.
- The current Ubuntu `snap` (which provides 0.142.0) also works.

## Installation

- Install Hugo; follow the guidance on https://gohugo.io/getting-started/installing.
You'll need to install Go as well: see https://go.dev/
- Hugo installation is described at https://gohugo.io/installation
- On Ubuntu 24.04, the version installed by `apt` works.
- On Ubuntu 22.04 and older:
- `apt-get install hugo` would install a version that is too old.
- `sudo snap install hugo` installs a too recent version
- Install Hugo 0.126 or newer (required by the Hugo Relearn theme)
follow the guidance on <https://gohugo.io/installing>.
You'll need to install Go as well: see <https://go.dev/>
- On Ubuntu, use the `snap` package:
- `sudo snap install hugo` installs the current version
`apt-get install hugo` would install a version that is too old,
(this applies up to Ubuntu 24.04)

- To install Hugo from source, you need a recent `golang-1.2x` compiler:
- On Ubuntu 22.04, this can be done with:

```bash
sudo apt install golang-1.23-go
# Add it to your path, assuming your .local/bin/ is early in your PATH:
Expand All @@ -47,13 +38,65 @@ Hugo Relearn >= 5.24.0 and < 6.x are expected to work:
## Development

- Run a local server: `hugo server`
- Open a browser at http://127.0.0.1:1313/new-docs/
- Open a browser at <http://127.0.0.1:1313/new-docs/>
- Add content to `doc/content/`:
- Documents are written in Markdown.
- Please wrap lines in paragraphs to make review and diffs easier to read.
- The menu hierarchy comes mostly from the directory structure in `content/`.
- Please wrap lines in paragraphs to make reviews more manageable.
- The menu hierarchy comes mainly from the directory structure in `content/`.
- A file called `_index.md` is needed in a directory to define a new level in the menu.
- To set the page title which is also used for the main menu,
- To set the page title,
[use the front matter](https://gohugo.io/content-management/front-matter/).
- For a page that has images or other stuff included, it is best to create a new directory. Put the contents in a `index.md` file (no `_`) and the related files next to it. See https://gohugo.io/content-management/organization/ for more information.
- Look at https://mcshelby.github.io/hugo-theme-relearn/ for more information about what the Relearn theme offers, including some handy "shortcodes".
- For a page that has images or other stuff included, it is best to create a new directory:
Put the contents in an `index.md` file (no `_`) and the related files next to it.
See <https://gohugo.io/content-management/organization/> for more information.

See <https://mcshelby.github.io/hugo-theme-relearn/> for more information about
the features of the Relearn theme, including handy "shortcodes".

Note: When switching versions, before re-generating the documentation using
`hugo server`, delete the previously generated static site using `rm -r docs/public`.

### Notes for supporting current versions of Hugo and the Relearn theme

Backported fixes to support newer Hugo versions:

- `layouts/partials/header.html`, it fixes:
```js
ERROR deprecated: .Sites.First was deprecated in Hugo v0.127.0 and will be removed in Hugo 0.143.0. Use .Sites.Default instead.
```
- `layouts/partials/menu.html`, it fixes:
```js
ERROR deprecated: .Site.IsMultiLingual was deprecated in Hugo v0.124.0 and will be removed in Hugo 0.143.0. Use hugo.IsMultilingual instead.
```

The fixes for those issues were backported from the Hugo Relearn v7.x.x theme.
When updating to Hugo Relearn 7.x.x, please remove them (if possible).

#### Upgrading to the Hugo Relearn 7.x.x theme versions

The partials in `layouts/partials` contain code for rendering the XenAPI releases
and class reference:

These custom partials need updates to support the breaking changes of Hugo Relearn
7.0.0. Otherwise, the Relearn theme menu sidebar on those pages would be missing.
These are the pages to verify for correct menu rendering when updating to 7.x.x:

- XenAPI Reference: <https://xapi-project.github.io/new-docs/xen-api/classes>
- XenAPI Releases: <https://xapi-project.github.io/new-docs/xen-api/releases>

Hint: For upgrading the Hugo Relearn theme, you can use:

```bash
cd doc; hugo mod get -u github.com/McShelby/[email protected]
```

#### Summary

Hugo Relearn >= 5.23 and Relearn 6.x.x work now, 7.x.x is work in progress.

#### References

- Changes with Relearn 6.x:
<https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/6/#6-0-0>
- Breaking changes with Relearn 7.x (to be supported):
<https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/7/#7-0-0>
2 changes: 1 addition & 1 deletion doc/content/design/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "Design Documents"
menuTitle = "Designs"
linkTitle = "Designs"
+++

{{< design_docs_list >}}
2 changes: 1 addition & 1 deletion doc/content/toolstack/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: The XAPI Toolstack
menuTitle: The Toolstack
linkTitle: The Toolstack
weight: 10
---

Expand Down
2 changes: 1 addition & 1 deletion doc/content/toolstack/features/events/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "Event handling in the Control Plane - Xapi, Xenopsd and Xenstore"
menuTitle = "Event handling"
linkTitle = "Event handling"
+++

Introduction
Expand Down
2 changes: 1 addition & 1 deletion doc/content/xapi/cli/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "XE CLI architecture"
menuTitle = "CLI"
linkTitle = "CLI"
+++

{{% notice info %}}
Expand Down
4 changes: 2 additions & 2 deletions doc/content/xapi/guides/howtos/add-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ This document describes how to add a new class to the data model that
defines the Xen Server API. It complements two other documents that
describe how to extend an existing class:

* [Adding a field](add-field)
* [Adding a function](add-function)
* [Adding a Field]({{% ref add-field.md %}})
* [Adding a Function]({{% ref add-function.md %}})

As a running example, we will use the addition of a class that is part
of the design for the PVS Direct feature. PVS Direct introduces
Expand Down
2 changes: 1 addition & 1 deletion doc/content/xapi/memory/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "Host memory accounting"
menuTitle = "Memory"
linkTitle = "Memory"
+++

Memory is used for many things:
Expand Down
2 changes: 1 addition & 1 deletion doc/content/xapi/storage/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "XAPI's Storage Layers"
menuTitle = "Storage"
linkTitle = "Storage"
+++

{{% notice info %}}
Expand Down
2 changes: 1 addition & 1 deletion doc/content/xapi/walkthroughs/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "XAPI requests walk-throughs"
menuTitle = "Walk-throughs"
linkTitle = "Walk-throughs"
+++

Let's detail the handling process of an XML request within XAPI.
Expand Down
2 changes: 1 addition & 1 deletion doc/content/xapi/walkthroughs/migration_overview.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "From RPC migration request to xapi internals"
menuTitle = "How XAPI handles migration request"
linkTitle = "How XAPI handles migration request"
+++

## Overview
Expand Down
2 changes: 1 addition & 1 deletion doc/content/xenopsd/walkthroughs/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "Operation Walk-Throughs"
menuTitle = "Walk-throughs"
linkTitle = "Walk-throughs"
+++

Let's trace through interesting operations to see how the whole system
Expand Down
2 changes: 1 addition & 1 deletion doc/content/xenopsd/walkthroughs/live-migration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "Live Migration Sequence Diagram"
menuTitle = "Live Migration"
linkTitle = "Live Migration"
+++

{{<mermaid align="left">}}
Expand Down
2 changes: 1 addition & 1 deletion doc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module xapi-project.github.io

go 1.20

require github.com/McShelby/hugo-theme-relearn v0.0.0-20231029175538-7ae1435626d7 // indirect
require github.com/xenserver-next/hugo-theme-relearn v0.0.0-20250130115402-72a6a157db2c // indirect
13 changes: 11 additions & 2 deletions doc/hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ assetsDir = "assets"

[module]
[[module.imports]]
path = 'github.com/McShelby/hugo-theme-relearn'
path = 'github.com/xenserver-next/hugo-theme-relearn'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

Copy link
Collaborator Author

@bernhardkaindl bernhardkaindl Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It is only an intermediate step in making progress with a small PR.

We could go to Relearn 7 directly on one hop, but then the PR would be far more extensive.
In this case, this intermediate line would not show up in the final change, it would
be reverted to the official Relearn 7 repo in the second part of that future PR.
However, that cumulative PR would be more significant than two smaller step-by-step PRs.

A fuller explanation

This is only a good intermediary step before the next update which then could upgrade the Relearn theme to the current version of Relearn.

I asked Sören Weber (https://github.com/McShelby, the author of Relearn) if he could help. He responded, "The file structure of your repo is uncommon." and linked to one hint. This also suggests that some changes to the structure of the partials might be needed for Relearn 7.

I meanwhile researched the compatibility with upstream Relearn 7 further

According to this, the final update to the current Relearn 7 will need a small structural change as Relearn 7 does not support the architecture of how XenAPI classes and releases are typed, and it suggests that content-generating code should be moved to the content.html partial as documented in the Relearn documentation at https://mcshelby.github.io/hugo-theme-relearn/configuration/customization/partials/index.html

Using this guidance, I've found a working solution for those issues, which, instead of special types for XenAPI classes and releases, which need to be maintained and can no longer include the header.html and footer.html (those don't exist in Relearn 7).

Instead, the code in the classes and releases partials should be merged into a content.html template to generate that content. I have a proof-of-concept: It updates the nearly empty class and release files (140 files) and merged the content generation into a new content.html partial according to the Hugo documentation.

But let's return to this PR, which is just a relatively small second intermediary step:

I solved the issues taken initially during the review by changing the URL of the Relearn module to a fork of Relearn that we can use without having to copy partials from Relearn (like I initially had):

Here are the details

For the details of the issue fixed in the PR and the full update to Relearn 7,
I asked Sören Weber (the author of Relearn) in McShelby/hugo-theme-relearn#1004 if he has some guidance on how to resolve the issue at hand.
He linked to https://mcshelby.github.io/hugo-theme-relearn/configuration/customization/designs/index.html#migration-to-relearn-7-or-higher.
Here is his answer: McShelby/hugo-theme-relearn#1004 (comment)

This solution goes in this direction: It compromises between ease of use (in this case, support for using the Ubuntu snap package and any new build of Hugo in general) and using a moderately new version (or, in this case, fork) of Relearn with the needed fixes.

Conclusion

After solving the compatibility issue and updating Relearn 7.x as described in the README.md, the upstream version will again be used. This is only an intermediate deviation from upstream to facilitate the upgrade.

Alternative

Not making this change would require installing a specific older version (possibly from the source) to generate the docs. This small change is more manageable than installing a special older version of Hugo for development and maintenance until all upgrade problems are fully solved.


# The latest upstream version of hugo-theme-relearn needs hugo 0.121.0:
# https://mcshelby.github.io/hugo-theme-relearn/basics/requirements/index.html
[module.hugoVersion]
min = "0.121.0"
min = "0.126.0"

# Newer Hugo needs to set the renderer to `unsafe = true` to support the raw HTML
# code that a number of pages intentionally use.
# goldmark is already the default renderer. The only change is the flag for raw HTML:
[markup]
defaultMarkdownHandler = 'goldmark'
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true

[outputs]
# Home and section pages should also have a print icon for the print view:
Expand Down