Easily restore your project to a previous version with our new Instant One-click Backup Recovery
Hygraph
Docs

Sectioned FAQ page

#Overview

This guide shows how to create an FAQ model that lets you add pre-created lists of Q&A pairs as sections.

You'll create a component as a template for the Q&A pairs, a model to store the Q&A pairs with data as lists with a title, and a model to let you create entries where you add this information through reference fields.

Sectioned FAQ pageSectioned FAQ page

This recipe is a great option if you prefer to work on Q&A lists as individual content pieces that you can easily add to another model to create topic-based FAQ sections on a page. It is also a great option if you need to show different sets of Q&A pairs throughout your website, as it allows you to create content entries grouping different configurations of questions and answers.

This image shows what a frontend using this setup could look like:

What this could look like on the frontendWhat this could look like on the frontend

#Prerequisites

  • REQUIRED: You need to have a Hygraph account. If you don't have one, you can sign up here.
  • REQUIRED: You need to have a Hygraph project. Look into the following section to learn more about your options.

#What you can do

Use this guide to create a Sectioned FAQ Page model. You have two options:

  • OPTION 1: Create a project. This is the way to go if you want to follow the entire tutorial for learning purposes.
  • OPTION 2: Use an existing project of yours. This is the way to go if you already have a project and want to add this model. In this case, you may need to adjust parts of the tutorial to your own project schema.

#Not in the mood to start building?

Clone the entire cookbook

This is the way to go if you're curious about how we built the FAQ recipes but don't want to follow the step-by-step creation process. This project contains the entire FAQ Cookbook so you can compare recipes or look into what instances they contain.

#Core concepts

In this guide, you'll work with different schema elements to create a Sectioned FAQ Page model. Let's look into them:

  • Model: Your schema is the content structure of your project. You can define your schema by creating models, adding fields, reusable components, and sidebar widgets, integrating remote sources, and establishing relationships with other models.
  • Component: a predefined set of fields that can be reused across models and content entries. You can think of a component as a flexible, reusable template: you define the fields that will be used inside a component once and then fill them with different content every time you use it in a content entry.
  • References: References are relations between two or more content entries in your project. With references, you can reuse content entries by connecting them. Once the relation is configured, you can also create related content directly from the content form.

#Step-by-step guide

This video follows the same step-by-step tutorial offered in this document.

#1. Build the component

We will create a component that will allow us to create different sets of questions and answers.

Simple FAQ componentSimple FAQ component

In the Schema builder, click +Add next to Components and use the following information:

FieldInput
Display nameSimple FAQ Component
API IDSimpleFaqComponent
API ID PluralSimpleFaqComponents

Click Add component to save.

Now that you've created the component itself, it's time to add fields to it. This will be a very simple component that only contains a Single line text field for the question, and a Rich Text field for the answer.

We'll start with the question. Add a Single line text field from the right sidebar, and use the following information:

TabFieldInput
SettingsDisplay nameQuestion
SettingsAPI IDquestion
SettingsDescriptionWrite the question here
SettingsUse as title fieldLeave this checkbox selected
ValidationsMake field requiredSelect this checkbox
ValidationsSet field as uniqueSelect this checkbox

Click Add to save.

This field configuration ensures that editors won't be able to repeat the exact same question on a list.

Next, you want include a rich text field for the answer, which will also allow some formatting. Add a Rich text field from the right sidebar, using the following information:

TabFieldInput
SettingsDisplay nameAnswer
SettingsAPI IDanswer
SettingsDescriptionWrite the answer here

Click Add to save.

Now that our simple FAQ component is ready, we can create the first model.

#2. Create the FAQ list model

This model will let you create lists of Q&A pairs as content entries.

To create the model, navigate to the Schema builder and click +Add next to Models. Use the following information:

FieldInput
Display nameFAQ List Group
API IDFaqListGroup
API ID PluralFaqListGroups

Click Add Model to save.

Now that the model has been created, you can start adding fields to it.

We will add a Single line text field to use as title, and a Basic component field to hold the component that we created in the previous step.

Let's start with the title. Add a Single line text field from the right sidebar, and use the following information:

TabFieldInput
SettingsDisplay nameFAQ Title
SettingsAPI IDfaqTitle
SettingsDescriptionFAQ group title
SettingsUse as title fieldLeave this checkbox selected
ValidationsMake field requiredSelect this checkbox
ValidationsSet field as uniqueSelect this checkbox

Click Add to save.

This configuration ensures that editors can't create lists without a unique name.

It's time to add the Simple FAQ component that you built earlier. Add a Basic component field from the right sidebar, using the following information:

TabFieldInput
SettingsDisplay nameQ&A Pair
SettingsAPI IDqAPair
SettingsDescriptionAdd a pair of question and answer fields
SettingsAllow multiple valuesSelect this checkbox
SettingsSelect a componentUse the dropdown to select Simple FAQ Component.

Click Add to save.

We chose to create the FAQ list as a model because in a use case like this, we want to create question & answer sets as content entries that can be easily referenced in other models later on. In the next step, we will create the Sectioned FAQ Page Model with a reference field that connects this model, which will allow editors to quickly set up FAQ landing pages containing topic-based FAQ sections.

#3. Create the FAQ page model

To create the FAQ page model, navigate to the Schema builder and click +Add next to Models. Use the following information:

FieldInput
Display nameSectioned FAQ Page
API IDSectionedFaqPage
API ID PluralSectionedFaqPages

Click Add Model to save.

This model will contain only two fields: a Single line text field for the page title, and a Reference field to add lists of Q&A from the model you created in the previous step.

Let's start with the title. Add a Single line text field from the right sidebar, and use the following information:

TabFieldInput
SettingsDisplay namePage title
SettingsAPI IDpageTitle
SettingsDescriptionWrite a page title here
SettingsUse as title fieldLeave this checkbox selected
ValidationsMake field requiredSelect this checkbox
ValidationsSet field as uniqueSelect this checkbox

Click Add to save.

This configuration ensures that all FAQ Page entries contain a unique title that will allow easy identification in the content form.

Next, you will create a reference field that editors can use to add content entries from the model you created in the previous step.

Add a Reference field from the right sidebar, using the following information:

TabFieldInput
DefineAllow only one model to be referencedSelect this radio button.
DefineModel to referenceuse the dropdown to select FAQ List Group
DefineReference directionUse the radio button to select One-way reference
DefineRelation cardinalityOne to many
DefineAllow multiple (…)Select this checkbox
ConfigureDisplay nameFAQ List
ConfigureAPI IDfaqList
ConfigureDescriptionSelect a list of questions and answers

Click Add to save.

Your model is ready! This is how you build a Sectioned FAQ Page model that lets you add lists of questions & answers to a content entry. You can use this in your front end in different ways, such as rich text embeds or landing pages.

#Resulting content form

If you followed this tutorial, your resulting content form should look like this:

Resulting content formResulting content form

Editors will be able to easily create FAQ pages by referencing lists from the FAQ List model. The FAQ Pages they create could contain a single Q&A list, or several ones.