Adding FAQ (Frequently Asked Questions) Schema to Hugo-based website

As part of “Give back to the community” I created a post about implementing FAQ Schema into a Hugo-based website. I hope you will find it helpful.

6 Likes

It can also be done with the same logic as the question asked in the topic here. I already asked the question to add a data schema to the head section when using the frequently asked questions shortcode.

I am getting several <!-- raw html omitted --> messages with this solution.

Could you clarify where exactly? Or could you share code so I can have a look?

I followed the tutorial. I created both question and answer shortcodes, added the shortcodes in my markdown file, added front matter, edited the renderlink.html file…but this happens.

<div>    <!-- raw HTML omitted -->
<h2 id="customers-asking-me-how-to-do-this-fancy-thing" itemprop="name">Customers asking me how to do this fancy thing?
</h2><!-- raw HTML omitted -->
<!-- raw HTML omitted -->

Could you let me know if you add

[markup]
  [markup.goldmark]
    [markup.goldmark.renderer]
      unsafe = true

into your config file (config.toml or hugo.toml) if that change?

If not, could you send me link to your repo so will have a look.

Yes it does. I should have mentioned I tested with unsafe = true and it worked. But with Hugo’s default unsafe = false, it does not.

1 Like

Thanks for checking this out.

I am using this by default on all my sites hence totally forget. Will update my post shortly :wink:

Alright. Using this method, here’s the result

 <!-- raw HTML omitted -->
<p>To make this fancy thing you need to have this fancy stuff.
<!-- raw HTML omitted -->
<!-- raw HTML omitted --></p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<p>You will need fancy elements and fancy liquid.
<!-- raw HTML omitted -->
<!-- raw HTML omitted --></p>
<!-- raw HTML omitted -->

Could you share the repository, so will be able to look at this?

If your repository is private, add me (temporarily) as a collaborator and I will be able to pull it to my end.

It replicates even on new installs with unsafe = false by default. Here’s a test site (open post 1 then view source)

You need to have this added to your config.toml file as mentioned before and than its working fine.

Add that to your post as a note. I do not want to enable that option, so I will be looking for an alternative method. Cheers.

It’s added now.