Orchard Core Introduction - Part 1 : Setting Up Your First Site

Allow me to reminisce on our love for Orchard CMS

Cloud Construct has been working with Orchard CMS since version 1.4. This is roughly 5 years of developing and advocating for a content management system that has a smaller following than most, but a community that is very passionate about the platform. When Cloud Construct first started out, the companies that we were working with were not able to budget a large CMS implementation for their corporate websites. Many of these implentations involve a large up-front cost, maintenance fees, and a gigantic hosting footprint. Locating developers to support them as well can be difficult and be expensive. Our clients needed a way to easily edit content, a secure platform, and a CMS that allowed them to grow. Cost was also a very important factor. Many clients would often be asking about Wordpress as a free alternative and the simplicity of content management on the platform. Here at Cloud we have always been very Microsoft focused and outside of DotNetNuke there were zero options for a quality open source CMS solution. 

In 2011 came Orchard CMS. Something that my friend Bill Wilder mentioned to me in passing that he had heard about. I gave it a look and downloaded version 1.4. At that time ASP.NET MVC was just beginning to be adopted, as well as Code First database development. Many of these new tools I had not really sunk my teeth into and all were first class citizens in Orchard. The ramp up time on Orchard was steep at the beginning and still is for anyone trying to get into it. It is more of a "way of coding" or a "framework" then a CMS at times. I often find myself borrowing code from Orchard for other projects because it is so well done and organized. Over the years, Orchard stabilized from its 1.4 performance issues, it's 1.6ish content part shifts, and deployment options. And with the introduction of the designer module, it truly became a great option for anyone developing a new site who wanted to leverage .NET and Azure. Here at Cloud we use Azure heavily and Orchard being so tightly knit with it makes it so powerful for us. I truly owe the Orchard Community and the Orchard Steering/Project team a lot for their efforts building out Orchard and how it helped our company.

Fast forward to this Fall when the next version of Orchard built on .NET Core began to take shape. Again, we will be forced to learn a new way of Orchard coding along with becoming proficient in .NET Core. Here we go! Each year Cloud Construct nominates a worthy 503c charity to receive a free website to help promote their cause. Orchard Core takes everything that was great about Orchard and shifts it to the new .NET Core framework. The goal is to allow the great features and constructs that come out of Orchard to be leveraged without the CMS if you wanted by delivering it via Nuget. There is no way to migrate from the old to the new, so it has to be a clear decision on what you want to do either way. We decided Orchard Core would be a great candidate for our new Mended Little Hearts charity site because it takes some great features of Orchard and simplifies things for content managers. It puts performance paramount to everything and is built for Docker as well. Lastly, Orchard Core is a CMS...but it doesn't have to be. Remember when I told you about how we often leverage constructs and code from Orchard? Well Orchard Core truly is a coding framework, with the option to add content management in as a Nuget package. So, if you want to host a website and just leverage the Orchard hosting pipeline and other utilities you can. Persisting and versioning content is only an option. 

I hope you enjoy this multi-part blog as we walk you through our experience building out a brand new site on Orchard Core.

Downloading and Setup

A quick note. This is my first shot at standing up an Orchard Core site, so it may not be the best way...but it's how we went about it. And as always check the documentation page first at https://github.com/OrchardCMS/OrchardCore and leverage the Orchard Gitter feed at https://gitter.im/OrchardCMS/OrchardCore to get some assistance if needed.

If you follow the documentation on the Orchard Core GitHub page, it has you download the entire source in order to run the site. This is not necessary unless you plan on editing the Orchard CMS core codebase. The path we followed enabled us to get the latest updates of Orchard Core every night via the build and keep our code base very "lean and themed" as we say.

Step 1 : Create a brand new Visual Studio 2017 .NET Core project.

Choose the Empty project template.

You will see Startup.cs in the root directory. Here is where you add and modify some code. 

First add this block of code : services.AddOrchardCms(); to the ConfigureServices method. Second, comment out the app.Run() code block from the Configure method and add these lines of code as the last entry in that method : app.UseModules() and you also will want to add app.UserStaticFiles() as well. You can always browse to the source code versions at https://github.com/OrchardCMS/OrchardCore/tree/dev/src/OrchardCore.Cms.Web to see what the latest config settings are for Startup.cs and Program.cs.

Here is what it should look like when complete :

You will notice that you now have two errors you need to resolve before running. First off, we need to add the Orchard CMS as a Nuget package. That's right, a Nuget package. That's how Orchard Core is distributed. Everything is a Nuget package which can be easily referenced, updated, and distributed. So let's do that now.

Browse to Tools > Nuget Package Manager > Package Manager Settings

Add a new reference to the Orchard Core Package Gallery - https://www.myget.org/F/orchardcore-preview/api/v3/index.json

Now you can browse to Tools > Nuget Package Manager > Manage Packages For This Solution

Choose the Package Source in the top right to your new Orchard Core Gallery reference. Then make sure you're on the Browse tab and select "OrchardCore.Application.Cms.Targets". Select the package and then select your project on the right to install.

This will pull in a ton of dependencies obviously. Take a sip of coffee and....boom your errors are gone and you can run your project. Your packages canbe updated every day with the daily builds if you wish. Start the Orchard Core Web Project with or without debugging.

You should now see the new Orchard Setup screen!

Go ahead and fill out the options and choose the "Agency" recipe for a simple company website setup. If you're new to Orchard, you can choose some different database options as well as an account to access Orchard once setup completes. Once you Finish Setup you will get the new site running and see the Agency Theme activated!

Note : The Themes are packaged into the Core CMS Nuget package as a dependency. Because Orchard serves all assets as embedded resources, they are all embedded into the dlls of each Nuget package. This is why you don't see the normal css/js assets of the Admin and Agency themes. Crazy right?

You should now see the new Agency theme home page and be able to browse to the Admin dashboard via "/admin". 

And the new Admin Dashboard :

So we did it! We got Orchard Core running. This is the first step in beginning to build a brand new website. In the next part we will cover configuring our own theme that we can package and extend in Orchard Core.

Questions for the Cloud team? Please browse to our Contact Us page and let us know how we can help you get started with Orchard!

Jump into Theming in our second part to this series. Browse to Part 2 - Building A Custom Theme