Skip to content

Handle FAQs in a more flexible way

Currently, our FAQs will include JSON-LD. However, there is a limitation: there can only be one faq.json (per language).

https://gitlab.eclipse.org/eclipsefdn/it/webdev/hugo-solstice-theme/-/blob/main/layouts/faq/section.html?ref_type=heads

I'm adding a new FAQ to the Hugo eclipse.org, a site where there could be more FAQs in the future. Therefore, we'll need to resolve this limitation.

I've got two potential solutions.

Solution 1: Frontmatter and Data Files

Using frontmatter, we can target specific json-ld files to include on the page.

---
title: "Open VSX FAQ"
metadata:
 - path: "/path/to/json-ld.json"
   type: "json-ld"
---

{{< faq >}}

The faq shortcode will refer to the json-ld file and generate the HTML content.

Solution 2: Layout Param

We could also define a new layout for FAQs. We can set these up to automatically include the json-ld on the page.

I was thinking we could generate a JSON-LD file from the markdown content. This could be done with js.Build https://gohugo.io/hugo-pipes/js/

This would make it easier to internationalize the content. It would also be easier to modify and maintain than to write the markup in a JSON file.

However, this solution could take more time to implement.

---
title: "Open VSX FAQ"
layout: "faq"
---