Creating a decoupled blog and website with Orchard Core CMS -Part 1

...

This is the first in a series of articles in which I will be creating a website with a blog using a decoupled Orchard CMS. In this post we will be creating a most basic frontend backed by the Orchard CMS. 

I am using Visual Studio 2019. The first step is to create a new project - of ASP.NET Core Web Application.

On the next page  select it as Web Application.

 

You could run it at this point and have the basic starter web app. It contains a couple of default razor pages - index, layout etc. In a traditional CMS the CMS would be responsible for creating all the pages and their styling. With a decoupled CMS we control those aspects, but rely on the CMS to provide the data that we populate the pages with. The CMS will also provide a lot of the plumbing. We turn it into an Orchard Core CMS decoupled app by installing an Orchard Core nuget package.

Open nuget package manager and install OrchardCore.Application.Cms.Core.Targets

At the time of writing this post Orchard Core is still pre-release so you may have  to check the Include Prerelease checkbox. I'm currently using RC2 (v.13450).

Click the acceptance notices and wait a while as it downloads and installs a host of dependencies.

.NET Core comes with a built in DI container. We can register services with this container in the startup class. Orchard Core CMS is actually comprised of Orchard Core and Orchard Core CMS. Orchard Core is a framework that enables the project to run other Orchard Core enabled modular apps within it. Orchard Core CMS is a modular app running within that framework. We can look at the implications of that and how to utilise modules within our app in another post. For now its enough to know that in startup we need to enable the app to use Orchard Core. Then we need to Add the Orchard Core Module to the list of registered modules. As mentioned earlier Orchard core takes care of some of the plumbing, including the routing and use of razor pages. As such  you need to replace everything in the startup class Configure method, that comes after app.UseStaticFiles(); with app.UseOrchardCore();

Then register the CMS module by adding services.AddOrchardCms(); to the ConfigureServices method.

The next step is to run the application with Ctrl+F5. This will build the app and cause the Orchard Core CMS Setup screen to appear. One of the options here is to specify the database that will be backing the CMS. One of the Options is SQL Lite, which will be created for you as part of the process. For the other db options such as SQL Server or MySQL you will need to have the db configured with a user id/password.

Assuming you have the database connection details to hand or are using sql lite then run the application. Select Blank Site from the recipe dropdown and enter in the database details as well as the other fields.

The CMS will then be created and the default home page will then be fired up. The 

The website you see here has nothing at present coming from the CMS. We will cover that in the next post. The CMS is there and present though, as you can see if you then add /admin to the URL. This will prompt you for a user id and password. These will be the userid and password you entered in the setup screen.

 

In the next post we will use this admin screen to define some content types and link our web application to display them.