Blocks FAQ page
#Overview
Join our community to suggest new recipe ideas!
This guide shows how to create an FAQ model that lets you add Q&A pairs as blocks.
You'll create a model to store the Q&A pairs with data, a component for the blocks, and a model that will let you add blocks of topic-based FAQ lists.
Blocks FAQ Page
This recipe is a great option if you prefer to work on Q&A pairs as individual content pieces that you can easily add to another model to create the FAQ list. It is also a great option if your users would benefit from a sectioned FAQ landing page that groups questions and answers by topic.
This mock image shows what a frontend using this setup could look like:
Mock image
#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 Blocks 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.
- Take plan limits into consideration when adding a recipe to your own project.
- Are you new to Hygraph? You may want to check out our Getting Started Tutorial!
#Not in the mood to start building?
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 Blocks 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. Create the FAQ list model
This model will let you create 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:
Field | Input |
---|---|
Display name | FAQ List Single |
API ID | FaqListSingle |
API ID Plural | FaqListSingles |
Click Add Model
to save.
Let's add fields to this model. We will add a Single line text
field to use as question, and a Rich Text
field for the answer.
For the question, add a Single line text
field from the right sidebar, and use the following information:
Tab | Field | Input |
---|---|---|
Settings | Display name | Question |
Settings | API ID | question |
Settings | Description | Write the question here |
Settings | Use as title field | Leave this checkbox selected |
Validations | Make field required | Select this checkbox |
Validations | Set field as unique | Select this checkbox |
Click Add
to save.
This configuration ensures all entries are created with their questions as title, for quick identification in the content form. These titles must also be unique, which will contribute to a good user experience for editors creating FAQ lists.
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:
Tab | Field | Input |
---|---|---|
Settings | Display name | Answer |
Settings | API ID | answer |
Settings | Description | Write the answer here |
Validations | Make field required | Select this checkbox |
Click Add
to save.
In this case, we're not enabling embedding because we don't need to insert content from other Q&A pairs or even from other models in our simple setup. Consider enabling embedding if your content can benefit from it.
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 and components later on. In the next step, we will create the FAQ Block component with a reference field that connects this model. This will allow editors to quickly link Q&A pairs to form lists.
#2. Create the block component
To create the component, navigate to the Schema builder and click +Add
next to Components. Use the following information:
Field | Input |
---|---|
Display name | FAQ Block |
API ID | FaqBlock |
API ID Plural | FaqBlocks |
Click Add component
to save.
This component will contain only two fields: a Single line text
field for the block title, and a Reference
field to add Q&A pairs from the model you created in the previous step.
We'll start with the title. Add a Single line text
field from the right sidebar, and use the following information:
Tab | Field | Input |
---|---|---|
Settings | Display name | Block title |
Settings | API ID | blockTitle |
Settings | Description | Add a title for this FAQ Block |
Settings | Use as title field | Leave this checkbox selected |
Validations | Make field required | Select this checkbox |
Click Add
to save. We decided to make it required so all blocks contain a title.
Next, you will create a reference field that will allow editors to add Q&A pairs from the model you created in the previous step.
Add a Reference
field from the right sidebar, using the following information:
Tab | Field | Input |
---|---|---|
Define | Allow only one model to be referenced | Select this radio button. |
Define | Model to reference | use the dropdown to select FAQ List Single |
Define | Reference direction | Use the radio button to select One-way reference |
Define | Relation cardinality | One to Many |
Define | Allow multiple (…) | Select this checkbox |
Configure | Display name | Q&A Pairs |
Configure | API ID | qAPairs |
Configure | Description | Select Q&A pairs to form a list |
Click Add
to save.
Your component is ready! In the next step, we will add it to a model to create an FAQ landing page that may contain one or more blocks of FAQ.
#3. Create the FAQ page model
To create this model, navigate to the Schema builder and click +Add
next to Models. Use the following information:
Field | Input |
---|---|
Display name | Blocks FAQ Page |
API ID | BlocksFaqPage |
API ID Plural | BlocksFaqPages |
Click Add Model
to save.
This model will contain only two fields: a Single line text
field for the page title, and a Basic component
field to add blocks of Q&A pairs.
First, we'll add the title. Add a Single line text
field from the right sidebar, and use the following information:
Tab | Field | Input |
---|---|---|
Settings | Display name | Page title |
Settings | API ID | pageTitle |
Settings | Description | FAQ landing page title |
Settings | Use as title field | Leave this checkbox selected |
Validations | Make field required | Select this checkbox |
Validations | Set field as unique | Select 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 add a basic component field that will allow editors to add blocks of questions and answers.
Add a Basic component
field from the right sidebar, using the following information:
Tab | Field | Input |
---|---|---|
Settings | Display name | FAQ Block |
Settings | API ID | faqBlock |
Settings | Description | Add an FAQ Block |
Settings | Allow multiple values | Select this checkbox |
Settings | Select a component | Use the dropdown to select FAQ Block. |
Click Add
to save.
Your model is ready! This is how you build a landing page for FAQ where lists of questions and answers can be added as blocks.
#Resulting content form
If you followed this tutorial, your resulting content form should look like this:
Resulting content form
Editors will be able to easily create FAQ blocks by referencing Q&A pairs.