Linking Documents and Media
The most challenging aspect of building static sites is creating links that work consistently across different deployment scenarios. MyLittleContentEngine solves this through automatic BaseUrl-aware link rewriting that ensures your links work seamlessly whether deployed at the root domain or in a subdirectory.
The Deployment Challenge
Static sites often need to work in multiple deployment contexts:
- Local development:
http://localhost:5000/
- Production at root:
https://mydomain.com/
- Production in subdirectory:
https://mydomain.github.io/my-repo/
- Versioned in subdirectory:
https://mydomain.github.io/my-repo/v4/
The same site must generate correct links regardless of where it's deployed. MyLittleContentEngine's automatic link rewriting handles this complexity for you.
Understanding BaseUrl
The BaseUrl
setting tells MyLittleContentEngine where your site will be deployed. This is critical for ensuring links work across different deployment scenarios and is now configured via command line arguments using OutputOptions.
Quick BaseUrl Setup
builder.Services.AddContentEngineService(_ => new ContentEngineOptions
{
SiteTitle = "My Documentation Site",
SiteDescription = "Technical documentation",
ContentRootPath = "Content",
});
Tip
Link Types and Best Practices
MyLittleContentEngine supports different linking patterns to suit various use cases:
Relative Links
Best for linking between closely related content:
<!-- Within same directory -->
[Related Article](./related-article)
[Local Image](./images/diagram.png)
<!-- Parent/child navigation -->
[Parent Section](../index)
[Child Page](./subsection/details)
Absolute Links
Best for site-wide navigation and assets:
<!-- Site navigation -->
[Documentation](/docs)
[API Reference](/api)
[Home Page](/)
<!-- Static assets -->

[Download PDF](/files/guide.pdf)
Cross-References (xref)
For linking to documented APIs and types:
<!-- Link to API documentation -->
[ContentService](xref:MyLittleContentEngine.ContentService)
[Configuration Guide](xref:docs.guides.configuration)
<!-- Shorthand syntax using xref tags -->
<xref:MyLittleContentEngine.ContentService>
<xref:docs.guides.configuration>
The <xref:uid>
syntax provides a convenient shorthand that automatically uses the target's title as the link text. Both approaches resolve to the same output, but the tag syntax is more concise when you want to use the document's actual title.
Note
External Links
For referencing external resources:
<!-- External sites -->
[Microsoft Docs](https://docs.microsoft.com)
[GitHub Repository](https://github.com/example/repo)
Automatic Link Processing
MyLittleContentEngine automatically processes links in your content to ensure they work correctly across different deployment scenarios. All root-relative URLs (starting with /
) are automatically adjusted based on your site's configuration.
Tip
Static Files in ContentRootPath
Static files like images, CSS, and JavaScript are served from the ContentRootPath
directory and automatically
processed:
In Markdown

[Download PDF](/documents/guide.pdf)
In Razor Components
<img src="/images/logo.png" alt="Logo" />
<a href="/documents/guide.pdf">Download Guide</a>
Testing Your Links
During development, verify that your links work correctly:
- Run locally: Use
dotnet run
to test in development - Check all link types: Verify relative, absolute, and cross-reference links work
- Test static generation: Use
dotnet run -- build
to test static output
Tip
Best Practices
Choose the right link type:
- Use relative links for closely related content
- Use absolute links for site-wide navigation and assets
- Use cross-references for API documentation
- Use external links for outside resources
Be consistent: Stick to a consistent linking pattern throughout your site
Use descriptive link text: Make links meaningful and accessible
Test regularly: Verify links work during development and after content updates
Leverage automatic processing: Let MyLittleContentEngine handle URL rewriting automatically
Summary
MyLittleContentEngine provides flexible linking options to connect your content effectively:
- Multiple link types support different use cases (relative, absolute, cross-reference, external)
- Automatic processing ensures links work across deployment scenarios
- Static file integration handles images, documents, and other assets seamlessly
- Cross-reference system maintains links to API documentation and internal content
Use the appropriate link type for your content, and let MyLittleContentEngine handle the technical details of URL processing and deployment compatibility.