As a content repository, Kentico Cloud offers unlimited possibilities for delivering content to any device, displayed in any format. When it comes to websites, a common use case is to use ASP.NET or .NET Core to create web pages driven by the content from Kentico Cloud. This brings the overheads of .NET development, hosting solutions (primarily Azure), and other requirements to get a website up and running.
In this post I will cover off a use case where a combination of services enabled the "Publish" button in Kentico Cloud to result in a static site being updated with the latest changes.
That's right - these pages are now simple HTML files, rendered from content stored in Kentico Cloud.
The process from publishing content changes, to deploying the updates is:
With content items stored in Kentico Cloud, the Kentico Cloud Delivery API enables easy retrieval of content, for further processing with Wyam. Using a plain text content element, with the appropriate processing in further steps, allows the use of Markdown for formatting the blog post contents.
Asset fields provide an easy way of inserting images & other assets.
From the wyam.io webpage:
It's a static content toolkit and can be used to generate web sites, produce documentation, create ebooks, and much more. Since everything is configured by chaining together flexible modules (that you can even write yourself), the only limits to what it can create are your imagination.
In a nutshell, Wyam accepts a set of input documents, does processing on the input files, and spits out documents as the output.
The Wyam configuration file (config.wyam
) defines the sequence of module execution (known as pipelines). For this blog, the sequence within Wyam is along the lines of:
To enable Wyam to use content items from Kentico Cloud, the missing piece in the puzzle was a custom library that will enable Wyam to retrieve Kentico Cloud content, and use it as the input for further processing. As there were no readily available solutions, I went ahead with writing a simple library that retrieves content from Kentico Cloud, and allows it to be used within Wyam.
The KenticoCloud.Wyam
library is still in a prototype phase, however it is available on GitHub and NuGet, with plans for ongoing development.
The library is loaded with a simple NuGet directive within the config.wyam
configuration file, and can then be used as part of a document processing pipeline.
#n KenticoCloud.Wyam
. . .
Pipelines.Add("BlogPosts",
KenticoCloud("(project id)")
.WithContentType("blog_post")
.WithContentField("body"),
KenticoCloudAssetParser(),
Markdown(),
Meta("Body", @doc.Content),
Merge(ReadFiles("blogpost.cshtml")),
Razor(),
WriteFiles($"blog/{@doc["url_slug"]}.html")
);
As the goal was to keep the hosting requirements as minimal as possible, Netlify was my choice of hosting service. The features that sealed the deal were:
Wyam runs on the .NET Framework, and requires a Windows environment to run. VSTS is a great continuous integration offering by Microsoft, and a perfect environment to generate the static site in an automated manner.
VSTS acts as a task runner, running the Wyam site generation process, and deploying the generated content to Netlify.
With automated builds set up in VSTS, it would be tedious if a new build of the static site had to be manually triggered within the interface of VSTS. Kentico Cloud's webhooks feature allows for the VSTS build to be triggered every time content is published within Kentico Cloud.
Azure Logic Apps provide a way of easily triggering VSTS builds via a webhook URL. An offering that is part of Azure, Logic Apps help with automating processes and integrating various services, through a simple graphical user interface.
The HTTP request URL for the Logic App is added as a webhook in Kentico Cloud, automating the build trigger in VSTS.
The advantages of switching to this setup are:
...and they come with some disadvantages:
This post marks the beginning of a series of blog posts, where I will cover off the setup & functionality of each of the elements that make these services work together.