Creating a custom module or theme for Orchard Core

Previously, we looked at how to get up and running with Orchard Core by using the NuGet package. In this post, we're going to create a custom module to plug in to Orchard Core. You'll need a web project that already has Orchard Core installed in to it, so if you haven't done so yet, you can achieve this in about five minutes by following the instructions here.

Creating the module project and reference

Open up Visual Studio with the solution that we created in the previous post. We'll add a new .NET Core Class Library project to contain our module:

Creating a module project

Unlike Orchard 1, Orchard Core requires a reference from the web project to each module or theme. This is the part that catches most people out, so let's go ahead and add the reference now so that we don't forget. Click Add Reference on the web project, and add a reference from the web project to the new module:

Adding a reference Reference Manager

Installing module requirements

Once we have a project, there's a few things that we need to add to the project in order for Orchard Core to recognize it as a module. Open up NuGet package manager, and install the OrchardCore.Module.Targets package (make sure you've got include prerelease ticked). This package includes (among other things) the abstractions we need to be able to add extension points. If you're creating a theme, install OrchardCore.Theme.Targets

The first thing we'll add is our startup class. This class allows us to hook in to the start up pipeline of Orchard Core; it's where we do things such as register dependencies, or routes. The most basic startup class looks like this:

using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;

namespace OrchardDemo.MyModule
public class Startup : StartupBase
public override void ConfigureServices(IServiceCollection services)

At this point, we can build and run. Log in to the admin panel of your site, and you'll see your module appear in the Modules page:

Feature Page

If you like, you can enable your new module (although it won't do anything just yet)- you're now able to start building out your module as you need.

This is the bare minimum required to create a module. In a later post, we'll look at common extension points, as well as how to define a manifest for your module.

Leave a comment