Generate content for static sites

Static site generators like Jekyll, Hugo, and Docusaurus expect Markdown files with YAML front matter. GroupDocs.Markdown can automatically generate front matter from document metadata.

Convert with front matter and relative images

using GroupDocs.Markdown;

var options = new ConvertOptions
{
    IncludeFrontMatter = true,
    HeadingLevelOffset = 1,   // Reserve H1 for the page title
    ImageExportStrategy = new ExportImagesToFileSystemStrategy("content/posts/images")
    {
        ImagesRelativePath = "images"
    }
};

MarkdownConverter.ToFile("annual-report.docx", "content/posts/annual-report.md", options);

// Output file starts with:
// ---
// title: "Annual Report 2025"
// author: "Finance Team"
// format: Docx
// pages: 24
// ---
//
// ## Executive Summary
// ...

annual-report.docx is a sample file used in this example. Click here to download it.

content/posts/annual-report.md (5 KB)
content/posts/images/img-001.png (4 KB)
content/posts/images/img-002.png (14 KB)
content/posts/images/img-003.png (15 KB)

Download full output

Batch-convert a folder for Hugo

using GroupDocs.Markdown;

string inputDir = "documents";
string outputDir = "content/docs";

var options = new ConvertOptions
{
    IncludeFrontMatter = true,
    HeadingLevelOffset = 1,
    ImageExportStrategy = new SkipImagesStrategy() // or file system
};

foreach (string file in Directory.GetFiles(inputDir))
{
    string ext = Path.GetExtension(file).ToLower();
    if (ext is ".docx" or ".pdf" or ".xlsx" or ".epub")
    {
        try
        {
            string outputPath = Path.Combine(
                outputDir,
                Path.GetFileNameWithoutExtension(file) + ".md");

            MarkdownConverter.ToFile(file, outputPath, options);
            Console.WriteLine($"Converted: {Path.GetFileName(file)}");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Skipped: {Path.GetFileName(file)} — {ex.Message}");
        }
    }
}
content/docs/business-plan.md (7 KB)
content/docs/cost-analysis.md (9 KB)

Download full output