Define a page content type
This page is part of a series you should follow sequentially from beginning to end. Go to the first step.
Previously, we created a reusable content type called Slogan. In order to use it in the website channel we defined in the last step, we’ll need a page content type. Pages of this type will reference reusable Slogan items.
Add a page content type in the admin UI
Begin by navigating to Configuration → Content types → New content type.
Fill in the form with the following properties:
- Display Name: Landing page
- Namespace: Kickstart
- Name: LandingPage
- Icon: xp-market (type ‘market’ in the select list search bar)
- Use for: select Pages from the dropdown
- Include in routing: True (checked)
Save and switch to the Fields tab of the new Landing page content type. Add a field called LandingPageSlogan. Define the following properties to enable this field to reference Slogan items from the Content hub:
Field name: LandingPageSlogan (we recommend using the <content type name><field name> naming convention as explained here)
Data Type: Content items (Pages and reusable content in newer versions)
Display in editing form: True (Enabled)
Field caption: Slogan
Form component: Content item selector (Combined content selector in newer versions)
Form component configuration → Allowed content type: Slogan
This links your reusable content type with the page and ensures only items of type Slogan will be allowed on any web page of type Landing page.
Your content type should look like this:
Our example page content type is very basic, with only one field. In production scenarios, the web page content type should also include reusable field schemas to represent structured data needed only for the web channel, such as those related to SEO, OpenGraph, and other web-specific metadata.
Link the type to the channel
Now you need to associate the page content type with the website channel from the previous step. Switch to the Allowed in channels tab of the content type, and click Select channels.
Select Kickstart pages, and save the selection.
The Kickstart pages channel now shows up as an item in the list. Additionally, if you navigate to Configuration → Channel management → Kickstart pages → Allowed content types, you will see the Landing page content type listed.
Pages and page templates
At this point, you are technically able to create a page of type Landing page in your Kickstart pages channel. However, if you are following along with the Kickstart series, do NOT create a new page of this type yet.
A future step in this series will show how to create page templates. Pages that are not assigned a page template at the time of creation cannot be assigned one at a later time.
Generate a class for the Landing page content type
Just like with the Slogan content type, you need to generate a class to access the Landing page content type in your .NET solution. Go to the Kickstart.Web project in a new command window and run the following command:
dotnet run --no-build -- --kxp-codegen --type "PageContentTypes" --location "../Kickstart.Entities/{type}/{name}" --include "Kickstart.LandingPage"
Find more information about code generation on this documentation page or this video.
After the command or script above completes, you should see a new LandingPage.generated.cs file in the ~/PageContentTypes/LandingPage folder of the Kickstart.Entities project.
In the next step, we’ll make some configurations to prepare the application to serve our page.
Previous step: Add a website channel — Next step: Configure the project to display content
Completed steps: 5 of 13