⚠️ This README is under construction.⚠️
This application serves as a supporting repository for a blog post series showing how to build a dynamic navigation menu using .NET Core MVC and the Kentico Kontent headless CMS. The project is broken up across different branches ("Parts") to showcase code changes throughout the different blog posts.
📰 links to the related blog post will be included when published.
To run the app:
- Clone the app repository with your favorite GIT client
- For instance, you can use Visual Studio, Visual Studio Code, GitHub Desktop, etc.
- Alternatively, you can download the repo as a ZIP file, however, this will not adapt line endings in downloaded files to your platform (Windows, Unix).
- Open the solution in Visual Studio.
To import the sample project:
-
Go to app.kontent.ai and create an empty project
-
Go to Project Settings > Localization
- Edit "Default Language" to be:
- Language name: English (United States)
- Codename: en-US
- Create new language:
- Language name: Spanish (Spain)
- Codename: es-ES
- Edit "Default Language" to be:
-
Go to Project Settings > API Keys, note the Project ID and Management API keys for later use
-
Install the Kontent Backup Manager and import data to newly created project from the part_four_backup.zip file (place appropriate values for apiKey and projectId arguments):
npm i -g @kentico/kontent-backup-manager kbm --action=restore --apiKey=<Management API key> --projectId=<Project ID> --zipFilename=part_four_backup
Alternatively, you can use the Template Manager UI for importing the content.
Note: All language variants in the Kentico Kontent project must be published. The Kontent Backup Manager does this by default, and there is a "Publish language variants after import" option in the Kontent Template Manager UI.
Perform the following steps to connect your MVC application to the imported project:
-
In Kentico Kontent, choose Project settings from the app menu.
-
Under Production Environment Settings, choose API keys and copy the Project ID.
-
Open the
appsettings.json
file. -
Use the values from your Kentico Kontent project in the
appsettings.json
file:- Project ID: Insert your project ID into the
ProjectId
application setting.
- Project ID: Insert your project ID into the
{
"DeliveryOptions": {
"ProjectId": "<your Kontent project ID>"
},
}
Note: The showcased navigation can be setup without Web Spotlight by manually creating the Homepage and Page content types.
Web Spotlight is used throughout the blog series and dictates the structure of the navigation menu. It is an additional (optional) tool for Kentico Kontent focused on website management. For this project, it allows for:
- Seeing the hierarchy of the navigation in a page tree
- Creating new pages from the page tree
- Previewing changes in the Kontent UI
Web Spotlight is a paid feature and must be activated by a member of the Kentico Kontent Sales team for your subscription before it can be used. More information about Web Spotlight and activation can be seen in the official Kentico Kontent documentation.
Web Spotlight uses Kentico Kontent's "Preview" functionality in order to show the live view of the site within the UI.
To set up preview URLs for your project:
- In Kentico Kontent, choose Project settings from the app menu.
- Under Environment settings, choose Preview URLs.
- Type in the preview URLs for each type of preview-able content.
More details about setting up preview and Web Spotlight can be seen in the official Kentico Kontent documentation.
Note: Preview URLs require an
https://
protocol and a URL accessible to Kontent. Without a valid SSL certificate, Kontent responds with secure connection errors. When developing apps locally, see how to serve pages over HTTPS in combination with ngrok's forwarded address.
This application uses route localization and tag helpers provided by the AspNetCore.Mvc.Routing.Localization package.