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

Footer with sections

#Overview

This guide shows how to build a sectioned footer component that references internal content.

This footer has three columns as sections: one for stores, one for social network links, and another for FAQ.

Footer component with fieldsFooter component with fields

#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.
    • OPTION 1: Create a project. This is the way to go if you want to follow the entire tutorial for learning purposes.
    • OPTION 2: Clone the basic project. If you're already familiar with Hygraph and only want to follow the parts of the tutorial where you create the headers & footers, you can start here.
    • OPTION 3: Clone the entire cookbook. This is the way to go if you're curious about how the headers & footers are made but don't want to follow the step-by-step creation process. This project contains the entire Headers & footers Cookbook so you can compare them, or look into what instances they contain.
    • OPTION 4: Use an existing project of yours. If you have a project already and want to add this footer to it, this is the way to go. In this case, you may need to adjust parts of the tutorial to your own project schema.

#Core concepts

In this guide, you'll work with a number of schema elements. Let's look into them:

  • Model: Your schema is the content structure of your project. You can define your schema by creating models and adding fields, reusable components, and sidebar widgets to them, as well as integrating remote sources and establishing relationships with other models.

  • 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 use it to create related content from the content creation screen.

  • 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.

  • Basic component field: a component is a special field type in your Hygraph schema that defines which components of which type can be used in a model. Component fields can be of basic or modular types. A basic component field can only have one component attached to it. You can limit the number of component instances to one, or allow multiple component instances to be added in the content entry.

#What you can do

This guide offers two paths:

  • Path 1: Use this guide to create a sectioned footer component that you can use in your project.
  • Path 2: Clone one of the projects we created for you. You can clone a project that only contains the basic models so you can work on the headers & footers right away, or you can clone the project that contains the entire Headers & footers cookbook to compare the different section configurations without having to clone multiple projects.

#Clone project

#Clone the basic project

We have prepared a project that contains all the base schema elements you need to create your headers & footers, in case you don't want to build them from scratch:

Clone this project

If you decide to clone this project, you can skip the base schema elements creation part of this tutorial, and start from this step.

#Clone the complete cookbook

We have prepared a project that contains the entire Headers & footers cookbook:

Clone this project

This cookbook contains all the recipes we have so far to create headers & footers, so you can compare the different field configurations without having to clone multiple projects.

To find this particular recipe in the cookbook project, navigate to the schema and look for the "Sectioned footer" component.

#Step-by-step guide

In this guide, we will create a footer component with a nested component field for links. Before we can build our footer component, we need to create other schema elements that will be a part of it.

We will divide this process in steps to make it more manageable:

  1. Create the shop model: We will create a sample Shop model to use in our internal links.
  2. Create the Socials model: We will create a model that will allow us to create content entries with links ot our social network accounts.
  3. Create the FAQ model & component: We will create an FAQ list model & and FAQ component to add to our footer.
  4. Create the footer component: We will create a footer component that you can later add as component field to your models.

#1. Create the shop model

Shop modelShop model

One of our footer sections will display a list of shops. We will create a Shop model that we will later link to our footer component through a relation.

In the Schema builder, we'll click +Add next to Models, and use the following information:

FieldInput
Display NameShop
API IDShop
API ID PluralShops

We'll click Add model to save.

Our model has been created but it's empty. To create a simple model that will contain basic shop information, we'll add the shop name, address, picture and location.

Let's start with the shop name, as a Single line text field. We'll find it on the Add fields right sidebar, and click Add on the field card to add it.

We'll use the following information:

TabFieldInput
SettingsDisplay NameShop name
SettingsAPI IDshopName
SettingsUse as title field checkboxLeave this checkbox selected

We'll click Add to save.

Next, we'll add another Single line text field for the shop address.

We'll use the following information:

TabFieldInput
SettingsDisplay NameShop address
SettingsAPI IDshopAddress

We'll click Add to save.

Finally, we'll add an Asset picker field, which will be our shop's image. We'll select the Asset picker field from the right sidebar and use the following information to create it:

TabFieldInput
SettingsDisplay NameShop picture
SettingsAPI IDshopPicture

We'll click Add to save.

Finally, we'll add a location field so Editors can show the shop location on a map. We'll select the Location field from the right sidebar and use the following information to create it:

TabFieldInput
SettingsDisplay NameLocation
SettingsAPI IDlocation

We'll click Add to save.

Now that we're done with our three models, let's create our links component!

#2. Create the Socials model

Socials modelSocials model

We will create a Socials model that will allow us to create different social network link content entries that we can later on add to our footer as relations.

In the Schema builder, we'll click +Add next to Models, and use the following information:

FieldInput
Display NameSocials
API IDSocials
API ID PluralSocialss

We'll click Add model to save, and start adding fields to this model.

We'll start with the social network name, as a Single line text field. We'll find it on the Add fields right sidebar, and click Add on the field card to add it.

We'll use the following information:

TabFieldInput
SettingsDisplay NameSocial network name
SettingsAPI IDsocialNetworkName
SettingsDescriptionAdd the social network name here
SettingsUse as title field checkboxLeave this checkbox selected

We'll click Add to save.

Next, we'll add a Slug field from the right sidebar, which will allow us to later on include URLs to link to our socials.

We'll use the following information:

TabFieldInput
SettingsDisplay NameSocial network URL
SettingsAPI IDsocialNetworkUrl
SettingsDescriptionAdd the social network URL here
SettingsLowercase checkboxLeave this checkbox selected
ValidationsSet field as unique checkboxLeave this checkbox selected
ValidationsMatch a specific pattern checkboxSelect this checkbox, and use the dropdown to select the URL pattern. Write "Input value does not match the expected format." in the Custom error message field.

We'll click Add to save.

Finally, we'll add an Asset picker field from the right sidebar, so we can include the social network icon as well.

We'll use the following information:

TabFieldInput
SettingsDisplay NameSocial network icon
SettingsAPI IDsocialNetworkIcon
SettingsDescriptionAdd the social network icon here

We'll click Add to save. We did not allow multiple values in this case, because we want to only be able to have one icon per social account.

#3. Create the FAQ model & component

FAQ modelFAQ model

We will create a FAQ list model that will allow us to create different sets of questions and answers.

In the Schema builder, we'll click +Add next to Models, and use the following information:

FieldInput
Display NameFAQ list
API IDFaqList
API ID PluralFaqLists

We'll click Add model to save, and start adding fields to this model.

We'll start with a Single line text field, which will be the space to write the questions. We'll find it on the Add fields right sidebar, and click Add on the field card to add it.

We'll use the following information:

TabFieldInput
SettingsDisplay NameQuestion
SettingsAPI IDquestion
SettingsDescriptionYou can write your question here
SettingsUse as title field checkboxLeave this checkbox selected

We'll click Add to save.

Next, we'll ad a Rich text field from the right sidebar, which will be the space to write the answer to the question that we enter in the previous field.

We'll use the following information:

TabFieldInput
SettingsDisplay NameAnswer
SettingsAPI IDanswer

We'll click Add to save.

Now that we've created the model, we'll create a FAQ component that will allow us to select FAQ questions & answer pairs to add to our footer as a list.

To build this, we'll click + Add next to Components and add it using this information:

FieldInput
Display NameFAQ
API IDFaq
API ID PluralFaqs

We'll click Add component to save. The final step, is to add a relation as an instance inside this component.

We'll find the Reference field on the Add fields right sidebar, and click Add on the field card to add it.

We'll use the following information:

TabFieldInput
DefineReference typeSelect Allow only one model to be referenced
DefineModels to referenceUse the dropdown menu to select FAQ list
DefineReference directionSelect One-way reference
DefineAllow multiple... checkboxSelect Allow multiple FAQ list per FAQ
Configure referenceDisplay NameFAQ list
Configure referenceAPI IDfaqList
Configure referenceDescriptionAdd question & answer sets from the FAQ list

We'll click Add to save.

Now that we have all the schema elements that, both directly and indirectly, will be a part of our final footer component, we'll go ahead and create it!

Footer component with fieldsFooter component with fields

We'll click + Add next to Components and add it using this information:

FieldInput
Display NameSectioned footer
API IDSectionedFooter
API ID PluralSectionedFooters

We'll click Add component to save, and then we'll start adding instances to it.

We want our footer to to have three columns, one for shops, one for our socials, and one for FAQ.

We'll start with the shops column. Let's add a Single line text field, which will be our column title. Let's add it by clicking Add on the Single line text field card on the right sidebar.

We'll use the following information:

TabFieldInput
SettingsDisplay NameColumn 1 title
SettingsAPI IDcolumn1Title
SettingsDescriptionThis is the title for the Locations column on the footer. You cannot edit this title.
SettingsUse as title field checkboxSelect this checkbox
AdvancedSet initial value checkboxand write "Our locations" in the Initial value input.
AdvancedField visibilityUse the dropdown to select Read only

We'll click Add to save. This configuration creates a read-only field in our content entry that will have the title we specified. This will ensure that our footers have the same titles, even when editors can pick what content goes in them.

Next, we want to add our shops here as a relation, so we'll add a Reference field field, using the following information:

TabFieldInput
DefineReference typeSelect Allow only one model to be referenced
DefineModels to referenceUse the dropdown menu to select Shop
DefineReference directionSelect One-way reference
DefineAllow multiple... checkboxSelect Allow multiple Shop per Sectioned footer
Configure referenceDisplay NameColumn 1 links
Configure referenceAPI IDcolumn1Links

We'll click Add to save.

The next column will contain our socials. Let's add a Single line text field, using the following information:

TabFieldInput
SettingsDisplay NameColumn 2 title
SettingsAPI IDcolumn2Title
SettingsDescriptionThis is the title for the Socials column on the footer. You cannot edit this title.
AdvancedSet initial value checkboxand write "Our Socials" in the Initial value input.
AdvancedField visibilityUse the dropdown to select Read only

We'll click Add to save. Just like before, this configuration creates a read-only field in our content entry that will have the title we specified.

Next, we want to add our socials here as a relation, so we'll add a Reference field field, using the following information:

TabFieldInput
DefineReference typeSelect Allow only one model to be referenced
DefineModels to referenceUse the dropdown menu to select Socials
DefineReference directionSelect One-way reference
DefineAllow multiple... checkboxSelect Allow multiple Socials per Sectioned footer
Configure referenceDisplay NameColumn 2 links
Configure referenceAPI IDcolumn2Links

We'll click Add to save.

The final column will contain our FAQ list. Let's add a Single line text field, using the following information:

We'll use the following information:

TabFieldInput
SettingsDisplay NameColumn 3 title
SettingsAPI IDcolumn3Title
SettingsDescriptionThis is the title for the FAQ column on the footer. You cannot edit this title.
AdvancedSet initial value checkboxand write "FAQ" in the Initial value input.
AdvancedField visibilityUse the dropdown to select Read only

We'll click Add to save.

Next, we want to add our FAQ question & answer pairs here as a Basic component field, using the following information:

TabFieldInput
SettingsDisplay NameColumn 3 links
SettingsAPI IDcolumn3Links
SettingsSelect componentUse the dropdown to select the "FAQ" component

We'll click Add to save. In this case, we did not allow multiple values, because the FAQ component already contains a reference field that allows multiple values. So, we can already add as many questions & answer pairs as we want to our footer.

This is how you create a sectioned footer component that references internal content in different ways.