Scott Hanselman

Headless CMS and Decoupled CMS in .NET Core

October 03, 2018 Comment on this post [20] Posted in DotNetCore
Sponsored By

Headless by Wendy used under CC https://flic.kr/p/HkESxWI'm sure I'll miss some, so if I do, please sound off in the comments and I'll update this post over the next week or so!

Lately I've been noticing a lot of "Headless" CMSs (Content Management System). A ton, in fact. I wanted to explore this concept and see if it's a fad or if it's really something useful.

Given the rise of clean RESTful APIs has come the rise of Headless CMS systems. We've all evaluated CMS systems (ones that included both front- and back-ends) and found the front-end wanting. Perhaps it lacks flexibility OR it's way too flexible and overwhelming. In fact, when I wrote my podcast website I considered a CMS but decided it felt too heavy for just a small site.

A Headless CMS is a back-end only content management system (CMS) built from the ground up as a content repository that makes content accessible via a RESTful API for display on any device.

I could start with a database but what if I started with a CMS that was just a backend - a headless CMS. I'll handle the front end, and it'll handle the persistence.

Here's what I found when exploring .NET Core-based Headless CMSs. One thing worth noting, is that given Docker containers and the ease with which we can deploy hybrid systems, some of these solutions have .NET Core front-ends and "who cares, it returns JSON" for the back-end!

Lynicon

Lyncicon is literally implemented as a NuGet Library! It stores its data as structured JSON. It's built on top of ASP.NET Core and uses MVC concepts and architecture.

It does include a front-end for administration but it's not required. It will return HTML or JSON depending on what HTTP headers are sent in. This means you can easily use it as the back-end for your Angular or existing SPA apps.

Lyncion is largely open source at https://github.com/jamesej/lyniconanc. If you want to take it to the next level there's a small fee that gives you updated searching, publishing, and caching modules.

ButterCMS

ButterCMS is an API-based CMS that seamlessly integrates with ASP.NET applications. It has an SDK that drops into ASP.NET Core and also returns data as JSON. Pulling the data out and showing it in a few is easy.

public class CaseStudyController : Controller
{
    private ButterCMSClient Client;

    private static string _apiToken = "";

    public CaseStudyController()
    {
        Client = new ButterCMSClient(_apiToken);
    }

    [Route("customers/{slug}")]
    public async Task<ActionResult> ShowCaseStudy(string slug)
    {
        var json = await Client.ListPageAsync("customer_case_study", slug)
        dynamic page = ((dynamic)JsonConvert.DeserializeObject(json)).data.fields;
        ViewBag.SeoTitle = page.seo_title;
        ViewBag.FacebookTitle = page.facebook_open_graph_title;
        ViewBag.Headline = page.headline;
        ViewBag.CustomerLogo = page.customer_logo;
        ViewBag.Testimonial = page.testimonial;
        return View("Location");
    } 
}

Then of course output into Razor (or putting all of this into a RazorPage) is simple:

<html>
  <head>
    <title>@ViewBag.SeoTitle</title>
    <meta property="og:title" content="@ViewBag.FacebookTitle" /> 
  </head>
  <body>
    <h1>@ViewBag.Headline</h1>
    <img width="100%" src="@ViewBag.CustomerLogo">
    <p>@ViewBag.Testimonial</p>
  </body>
</html>

Butter is a little different (and somewhat unusual) in that their backend API is a SaaS (Software as a Service) and they host it. They then have SDKs for lots of platforms including .NET Core. The backend is not open source while the front-end is https://github.com/ButterCMS/buttercms-csharp.

Piranha CMS

Piranha CMS is built on ASP.NET Core and is open source on GitHub. It's also totally package-based using NuGet and can be easily started up with a dotnet new template like this:

dotnet new -i Piranha.BasicWeb.CSharp
dotnet new piranha
dotnet restore
dotnet run

It even includes a new Blog template that includes Bootstrap 4.0 and is all set for customization. It does include optional lightweight front-end but you can use those as guidelines to create your own client code. One nice touch is that Piranha also includes image resizing and cropping.

Umbraco Headless

The main ASP.NET website currently uses Umbraco as its CMS. Umbraco is a well-known open source CMS that will soon include a Headless option for more flexibility. The open source code for Umbraco is up here https://github.com/umbraco.

Orchard Core

Orchard is a CMS with a very strong community and fantastic documentation. Orchard Core is a redevelopment of Orchard using open source ASP.NET Core. While it's not "headless" it is using a Decoupled Architecture. Nothing would prevent you from removing the UI and presenting the content with your own front-end. It's also cross-platform and container friendly.

Squidex

"Squidex is an open source headless CMS and content management hub. In contrast to a traditional CMS Squidex provides a rich API with OData filter and Swagger definitions." Squidex is build with ASP.NET Core and the CQRS pattern and works with both Windows and Linux on today's browsers.

Squidex is open source with excellent docs at https://docs.squidex.io. Docs are at https://docs.squidex.io. They are also working on a hosted version you can play with here https://cloud.squidex.io. Samples on how to consume it are here https://github.com/Squidex/squidex-samples.

The consumption is super clean:

[Route("/{slug},{id}/")]
public async Task<IActionResult> Post(string slug, string id)
{
    var post = await apiClient.GetBlogPostAsync(id);

    var vm = new PostVM
    {
        Post = post
    };

    return View(vm);
}

And then the View:

@model PostVM
@{
    ViewData["Title"] = Model.Post.Data.Title;
}

<div>
    <h2>@Model.Post.Data.Title</h2>

    @Html.Raw(Model.Post.Data.Text)
</div>

What .NET Core Headless CMSs did I miss? Let me know.

This definitely isn't a fad. It makes a lot of sense to me architecturally. Given the proliferation of "backend as a service" systems, DocumentDBs like Cosmos and Mongo, it follows that a headless CMS could easily fit into my systems. One less DB schema to think about, no need to roll my own auth/auth.

*Photo "headless" by Wendy used under CC https://flic.kr/p/HkESxW


Sponsor: Telerik DevCraft is the comprehensive suite of .NET and JavaScript components and productivity tools developers use to build high-performant, modern web, mobile, desktop apps and chatbots. Try it!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service
October 03, 2018 12:01
I imagine being able to manage the website with PowerShell could be fun...
October 03, 2018 12:35
Hi Scott, given that you have listed multiple headless CMSs, which one would you recommend to start with? Thanks!
October 03, 2018 14:50
Hi Scott,

I read "I wanted to explore this concept and see if it's a fad or if it's really something useful." in the intro. I'm missing the answer to that question ;)

What do you actually think about them? And the whole concept? Any experience yet? For me this is something I was always thinking about when implementing a CMS. Make your own web app, and have a CMS just for the content. Haven't been able to try it yet so was looking for your opinion. Thanks for the summary though!
October 03, 2018 20:05
Hey Scott, not sure if you are familiar with Kentico, but they are a wonder .NET based CMS platform. They also offer Kentico Cloud which is in Gartner Magic Quadrant for CMS and is a headless CMS solution. https://kenticocloud.com/headless-cms-guide. It's not free, but it is a great solution for this purpose.
October 03, 2018 20:59
Hey Scott, surprised you didn't mention Sitecore. Well, maybe not surprised; Sitecore is a commercial CMS provider. They offer a headless interface as well and are currently in the process of being ported to DotNet Core.
October 03, 2018 21:11
Hi Scott,

I’m one step ahead of you, I’m now looking at serverless CMS. It seems like lynicon would be a good option. Although I can’t seem to find examples. That’s what I get for living on the edge
October 04, 2018 2:29
If anyone is interested in exploring the whole universe of headless CMS systems, https://headlesscms.org is a great resource from the Netlify folks.

It’s also not a coincidence that one of the leading static site hosts is interested in the headless CMS concept - it’s a great match with static site generators. You author the content and store media in the CMS and then a hook/timer/etc. triggers the static generator, which pulls data for generation from the headless CMS.
October 04, 2018 2:58
I did a similar evaluation a few weeks ago but with a focus on the non-technical content writer experience and found a lot of these new headless CMSs had awful editors. Things like not saving content once the session times out, accidental page refresh clearing all your work, no localization support, and limiting them to the typical tinyMCE controls. Only WordPress, especially with Gutenberg, had a great content writer experience and although it’s not exactly headless with JSON APIs everything is accessible via built-in services that’ll work with static site generators like gatsby.
October 04, 2018 3:11
Hi Scott,
It would be nice if you could add Sitecore CMS as that is widely used by so many companies including banks, travel websites etc.
October 04, 2018 12:36
Ive been using ButterCMS and have nothing but good things to say. I love using a headless CMS and the flexibility that it provides.
October 04, 2018 16:42
Hey Scott,

Thanks for the write-up!

Hi Matt! Thanks for the kind words.

If anyone has any questions about headless / Butter, happy to chime in.
October 04, 2018 17:53
Hi Scott, I work on Cofoundry, it is an open source .NET Core CMS delivered as a NuGet package and is super flexible in how you deliver content. While we do have a visual editor tool for managing content in website pages it's entirely optional and all the data API's are there for you to expose however you want to.

We have a cat-rating sample app that shows how to do this by exposing content data over web api.
October 04, 2018 18:51
This is super timely, for me -- it fits well with something I'm tasked with completing at the moment, so thanks for taking the time to put this together!

I had a quick laugh, though, as someone who was developing software going back to when Skype for Business was called Live Communications Server and did so through OCS, Lync and Skype for Business via TAP programs that former employers were involved in. When they switched the name to 'Lync', everyone around me groaned at the verbal disambiguation exercises with 'Link' that were going to all be part of our future.

People unfamiliar with the product never seemed to land on the odd spelling, but I thought I was the only one on the internet that somewhat frequently misspelled other words because of their edit distance from 'Lync'. TIL, I'm not alone (See Lynicon paragraph) -- and not terribly surprised since you're the owner of Can you hear me now which was my go-to for meetings when I was a remote worker relying on Lync/SfB. I'm betting you've typed that strange word more than me and it's pretty stuck muscle memory.

Thanks, again!
October 04, 2018 23:54
Hi Scott,

Thank you for covering this topic. We see the headless approach as an excellent option for developers who want to use microservices architecture, but also for front-end developers who want to build lightweight websites using modern frameworks, such as React or Angular, or static site generators, such as GatsbyJS.

That's why we created Kentico Cloud. As Kyle mentioned above, Kentico Cloud is a headless CMS with a strong .NET Core support.

Kentico Cloud runs on Azure, and it leverages many Azure services (Web Apps, Cosmos DB, Storage, Table Storage or - in the near future - Cognitive Services). Its API leverages a global CDN that makes your content available at no time anywhere in the world.

Our .NET SDK targets the .NET Standard 2.0, which means it can be used in .NET Framework 4.6.1 projects and above, and .NET Core 2.0 projects and above.

We also provide ASP.NET Core MVC Boilerplate, Xamarine Boilerplate and .NET model generator.

There's also a sample website in Microsoft Azure Gallery.

Since it's provided as SaaS, developers do not need to worry about installing and maintaining a CMS - they simply call its REST API or use one the SDKs that are available for all major languages.

For the business users, we provide excellent content authoring and collaboration experience (think of "Office online"-like experience for structured content).

Developers can easily get started with our free plan that can be used for commercial projects.

Happy to answer any questions.

Petr Palas, Kentico

Full disclosure: I work for Kentico, and I love headless, so my views may be biased.
October 05, 2018 6:49
aw shucks now I gotta try 'em all!
October 07, 2018 16:44
Hi,

Sebastian here, Main Developer of Squidex Headless CMS.

Thank you this free push and everything you do for the developer community.

Btw: Squidex is hosted with GCE, because they had the easier offer for startups at this time and kubernetes for Azure was not ready yet. Hope to change this soon.
October 08, 2018 23:59
I'm developing Kaliko CMS which just was released in version 1.2.4 introducing a new headless content API.

Kaliko CMS is a free and open source content management system for ASP.NET MVC and WebForms, and are currently undergoing a major rewrite to add .NET Core compatibility among other features.

A demo project showing the headless feature can be found here: https://github.com/KalikoCMS/DemoSite.Headless

And more information about the content API can be found here: http://kaliko.com/cms/get-started/use-as-a-headless-cms/
October 10, 2018 9:11
It's nice to see this list of .NET CMS platforms but we ended up going with WordPress for a recent project because we needed to monetize our content. The plugin PaidMembershipPro made this easy and turned our WordPress site into a SaaS with full membership and payment functionality. From the limited research I did with this list, it appears these .NET CMS platforms do not have this kind of SaaS functionality but please correct me if I am wrong.
October 16, 2018 7:24
I really enjoy reading this post. Thanks for sharing.
October 18, 2018 9:59
Hi Scott

We were super excited that you listed our Lynicon CMS in this blog, thanks so much.

Our aim with Lynicon was that in making it simply a Nuget package which provides CMS functions, to give developers a lot of the flexibility they love about headless in a fully featured CMS (which as you say you can just use as an API too). We avoided providing any functionality you can already get in ASP.Net Core, and also avoided using any ASP.Net Core extension points that would get in the way of an existing application, thus allowing you to retrofit Lynicon to an existing project. This means you can use any other Nuget packages or ASP.Net Core features you want and build your site the way you want with the minimum constraints from the CMS. In addition, we leveraged the standard ways of doing things in .Net Core to keep things simple, so content types are just C# classes and you write custom content queries with Linq.

Also, we made Lynicon highly switchable and extensible: out of the box it will work with any database with which you can use Entity Framework, and also you can store your data in a flat file which is great for smaller projects. You can write a provider for any data source you can think of, for instance we have one not released yet which lets you store data in Elasticsearch. The module system is very powerful which means not only can you add features like publishing content, almost more importantly, you can remove any features you don't need to simplify the front end and make the CMS run faster.

Thanks again for covering us Scott, it's an inspiration to move the project forward for us.

James (CEO Lynicon)

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.