Embedding External Content in Orchard Core

How to use a shortcode to embed content like markdown or code from external URLs in the Markdown or HtmlBody in Orchard Core.

Posted on February 23, 2025

I recently created an Orchard Core module that adds a shortcode for inserting external data into a HtmlBody or Markdown part or field. My motivation for creating this is that I wanted to include a recipe that I have as markdown on GitHub in a blog post. I didn't want to just copy the recipe because I'm slightly changing it fairly often and didn't want to have to update GitHub and my blog post. With this shortcode, I was able to have the recipe display in my blog post just like it was part of the blog post but when I change the recipe on GitHub, the changes show in the blog post as well.

The actual body of the post is this: TacoBellBody.png

You can see how it displays here: drewbrasher.com/blog/taco-bell-red-sauce

Here is the readme for the module (embedded from GitHub with the shortcode) if you would like to try it out.

External Data Module

An Orchard Core CMS module to embed the content of external URLs in Markdown or HtmlBody, with a shortcode.

NuGet Package

NuGet Version

Usage

You should only embed content like this for URLs that you have full control over.

Getting Started

  1. Add a reference to this module(DrewBrasher.OrchardCore.ExternalData) in your web application.
  2. Enable the "External Data" feature in the Orchard Core Admin UI.

External Content Shortcode

A shortcode for embedding the content of external URLs in Markdown or HtmlBody.

[external_content url='https://...' renderMode='MarkdownToHtml'][/external_content]

Arguments:

  • url: The url of the external content
  • renderMode (optional): How to render the content. Defaults to raw data if not specified. Supported values:
    • MarkdownToHtml: Renders markdown from the external source as HTML.

Example:

If you have a markdown file on GitHub with the url https://{YourGitHubRepoUrl}/readme.md that you would like to include in your Orchard Core blog post, you could put the shortcode in the MarkdownBody of your blog post:

[external_content url='https://{YourGitHubRepoUrl}/readme.md' renderMode='MarkdownToHtml'][/external_content]

The contents of the readme.md file would be rendered to HTML along with the rest of the MarkdownBody of your blog post.