Links and Navigation

Model a Menu and Add Content

Transcript

[00:00] Mr. McDonald is very happy with your work so far, but he also wants to add a menu to link to other pages and has sent you the design.

[00:06] So the first step is to build a menu type in Slice Machine. We know now that types are the models that will allow you to add the content in Prismic. The difference with this type is that it's not a page. So we will use a 'single' custom type called 'Global Nav'.

Global Nav

[00:21] There are no default metadata or SEO fields for these types. We can see from the design that we have, the company logo and a bunch of links. So to model this, add a text field called 'Company Name'

Company Name

[00:33] and a group field called 'Menu Items'.

Menu Items

[00:37] The group field will allow the users, Mr. or Mrs. McDonald, to add multiple instances of a group of fields. So inside the group field, add a link called 'Menu Link'

Menu Link

[00:47] and a key text called 'Menu Label'.

Menu Label

[00:53] The difference between a group field and a Slice is that the group field is only instantiated once in a type.

[01:01] Now navigate to Prismic. Click 'Create', choose the Global Nav type and add the company name. Then add the links and labels. Click the plus button to add a new element in the Menu Items group. Save and publish. Wow, that was fast.

Main takeaways

1. Create a menu custom type called "Global Nav".

2. In the static zone, add:

  • 1 x rich text field called "Company Name".
  • 1 x group field called "Menu Items".

3. Inside the group field, add:

  • 1 x link field called "Menu Link".
  • 1 x rich text field called "Menu Label"

4. Save and push to Prismic.

5. Add the company name and links to the Global Nav type in Prismic.

Extra info

Answer to continue

Quiz banner

Are there default SEO fields in custom types?