Repository navigation
4. Designing a theme
DasBlog Core uses Razor views for theming. Each theme is a self-contained folder that defines the layout, post templates, and styles for the site.
In the repository, themes are stored under:
source/DasBlog.Web/Themes/<theme-name>/
At runtime, this is the application's Themes/<theme-name>/ directory.
Theme development has two common starting points:
| Mode | Starting point | Goal |
|---|---|---|
| Greenfield | A current built-in theme or new design requirements | Create a new theme using the current DasBlog rendering model |
| Brownfield | An existing source theme, published installation, or legacy site | Preserve identity and behavior while modifying or modernizing the theme |
Both workflows should use a new theme name so the original remains available until the replacement has been validated and deployed.
DasBlog Core ships with six built-in themes:
| Theme | Description |
|---|---|
| dasblog | Default theme, clean Bootstrap 5 layout |
| darkly | Dark color scheme based on Bootswatch Darkly |
| flamingo | Pink accent palette |
| flatly | Flat, modern look based on Bootswatch Flatly (navy/blue accents) |
| kindofblue | Blue accent palette |
| median | Sidebar layout with summary cards (purple accents) |
All built-in themes target Bootstrap 5.3 and Font Awesome 6. They are protected and cannot be edited or deleted directly. To customize a built-in theme, create a copy using the theme editor.
The admin panel includes a theme editor at /admin/themes for managing themes directly from the browser.
- Browse themes - View all installed themes with status indicators (Active, Built-in)
- Create theme - Copy an existing theme as a starting point for a new custom theme
- Edit files - Edit supported text files with CodeMirror syntax highlighting
- Versioned backups - Each save automatically creates a backup (up to 3 versions retained)
- Revert changes - Restore a file to any previous backup version
- Set active - Switch the site to a different theme
- Delete - Remove custom themes (built-in themes and the active theme cannot be deleted)
Built-in themes are read-only. To customize one, create a copy first using the Create action.
To switch your active theme:
- Navigate to
/admin/themes - Click Set as Active on the theme you want to use
You can also change the Theme setting at /admin/settings.
The primary theme files form two rendering paths:
| Display mode | Page template | Item template |
|---|---|---|
| Full post | _BlogPage.cshtml |
_BlogItem.cshtml |
| Summary | _BlogPageSummary.cshtml |
_BlogItemSummary.cshtml |
_BlogPage.cshtml and _BlogPageSummary.cshtml receive a ListPostsViewModel. They normally delegate iteration to the shared _BlogItems and _BlogItemsSummary partials.
_BlogItem.cshtml and _BlogItemSummary.cshtml each receive a PostViewModel.
_BlogPage.cshtml is used for:
- An individual blog post
- Aggregate pages when Show item summary in aggregated views is disabled
It normally invokes _BlogItems, which renders each post with _BlogItem.cshtml.
When ShowItemSummaryInAggregatedViews is enabled, aggregate views such as the home page use _BlogPageSummary.cshtml.
It normally invokes _BlogItemsSummary, which renders each post with _BlogItemSummary.cshtml.
Summary mode does not apply to an individual post page.
Note
DasBlog static pages are separate from these blog page templates. Static pages are rendered by the application view Views/BlogPost/LoadStaticPage.cshtml.
A complete theme normally contains:
| File | Purpose |
|---|---|
_Layout.cshtml |
Master layout: HTML shell, metadata, navigation, footer, styles, and scripts |
_BlogPage.cshtml |
Container for full post rendering |
_BlogItem.cshtml |
Full post template |
_BlogPageSummary.cshtml |
Container for aggregate summary rendering |
_BlogItemSummary.cshtml |
Summary/card template for one post |
custom.css |
Theme-specific styles |
favicon.ico |
Optional theme favicon |
A theme can also contain images, fonts, JavaScript, and overrides for application views such as Archive.cshtml, ArchiveAll.cshtml, and Category.cshtml.
JavaScript files are not loaded automatically. Reference them explicitly from _Layout.cshtml, for example:
<script src="~/theme/my-theme/custom.js" asp-append-version="true"></script>Theme assets belong in the theme folder. Images and other files uploaded as blog-post content belong under the configured binary-content directory, normally content/binary.
Start with the current built-in theme closest to the required layout. A greenfield theme still needs the complete DasBlog template contract, authenticated controls, responsive behavior, and representative test content.
The recommended approach is to copy an existing theme from /admin/themes.
Create a theme based on the default dasblog theme:
dasblog-core newtheme <name>- Create
source/DasBlog.Web/Themes/<theme-name>/ - Copy the core files from an existing theme
- Customize the Razor views and CSS
- Set the theme as active at
/admin/themes
A brownfield theme can begin in a source checkout or a published installation.
Published themes are located under Themes/<theme-name>/, not
source/DasBlog.Web/Themes/.
- Identify the active production theme.
- Inventory its Razor files, CSS, JavaScript, images, fonts, external dependencies, content assets, and established routes.
- Copy the active theme under a new name.
- Make incremental changes.
- Track changes to the theme separately from changes to content and configuration.
- Keep the original theme and production settings unchanged until the new theme is deployed and approved.
When modernizing a legacy theme, replace obsolete Bootstrap, Font Awesome, and third-party framework usage with current bundled equivalents. Recreate only the rules required by the design rather than carrying forward unused vendor bundles.
Do not replace production configuration merely to test a theme.
For source development, use an appropriate local environment configuration and run the web project:
dotnet run --project source/DasBlog.WebFor a published site, an isolated preview is safer:
- Copy the published installation to a temporary location.
- Copy the required production configuration into Preview-specific configuration files.
- Change the root URL and active theme only in the Preview configuration.
- Set
ASPNETCORE_ENVIRONMENT=Preview. - Bind the preview to a loopback URL such as
http://127.0.0.1:5080. - Copy or link the working theme into the preview.
- Copy changed content files when the preview does not share content.
Confirm that the Preview environment is active before relying on these files. DasBlog caches XML content, so restart the preview after changing content XML. Theme CSS and other linked assets may update without a restart.
Keep theme presentation and site content separate:
| Change | Location |
|---|---|
| Razor, CSS, JavaScript, fonts, and theme images | Themes/<theme-name>/ |
| Posts and static-page content | Configured content directory |
| Images uploaded as post content | Normally content/binary
|
Static-page HTML can be stored as encoded text inside .dayentry.xml. Preserve
the XML encoding and parse every changed XML file before previewing or
deploying it.
Use root-relative links such as /contact-us for pages on the same site. Keep
external services, email links, production roots, canonical redirects, and
social metadata images absolute.
New themes should use the current tag helpers and view components rather than the obsolete compatibility partials:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="@Url.Content("~/")" />
<site-head-meta />
<site-rss-link />
<site-atom-link />
<twitter-card />
<open-graph />
<blog-posting-schema />
<link rel="stylesheet" href="~/lib/bootstrap/5.3.3/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/lib/font-awesome/6.7.2/css/all.css" />
<theme-stylesheets />
</head>
<body>
<header>
<!-- Navigation with <site-title /> or <site-title-link /> -->
<!-- Secure administrative controls with dasblog-authorized -->
</header>
<main class="container">
<vc:cookie-consent />
@RenderBody()
<site-page-control view-context="@ViewContext" />
</main>
<footer>
<site-copyright />
</footer>
<script src="~/lib/jquery/3.5.1/jquery.min.js"></script>
<script src="~/lib/bootstrap/5.3.3/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@RenderSection("scripts", required: false)
</body>
</html><theme-stylesheets /> loads both the shared site.css and the active theme's custom.css.
_BlogItem.cshtml renders a full post. Because it is also used on aggregate pages when summary mode is disabled, changes to this file can affect both individual posts and the home page.
@model PostViewModel
@{
ViewData["Title"] = Model.Title;
}
<article>
<h1><post-title-link post="@Model" /></h1>
<small><post-created-date post="@Model" /></small>
<post-content post="@Model" />
<p>
Categories:
<post-categories-list post="@Model">, </post-categories-list>
</p>
<div dasblog-authorized>
<post-edit-link post="@Model" />
<post-delete-link post="@Model" />
<comment-management-link post="@Model" />
</div>
<vc:related-posts post="@Model" count="5" />
<vc:collapse-comment-block post="@Model" />
</article>The related-posts component is optional. Its location in _BlogItem.cshtml controls where it appears, and its shared CSS classes can be styled in custom.css. For complete control over the markup, add Components/RelatedPosts/Default.cshtml to the theme. See Tag Helpers & Partial Views for details.
_BlogItemSummary.cshtml renders one compact post summary when aggregate summary mode is enabled:
@model PostViewModel
<article>
<post-categories-list post="@Model" />
<h2><post-title-link post="@Model" /></h2>
<small><post-created-date post="@Model" /></small>
<p><post-content post="@Model" strip-html="true" content-length="20" /></p>
<post-title-link post="@Model">Continue reading...</post-title-link>
<post-image post="@Model"
css="card-img"
default-image="/images/default/dasblog.svg?v=2" />
</article>For a complete list of available tag helpers and view components, see Tag Helpers & Partial Views.
- Check both full and summary aggregate modes.
- Check an individual post with a title, comments, categories, and administrative controls.
- Check static pages, archive pages, and category pages.
- Check desktop and mobile navigation and layouts.
- Verify theme asset paths separately from post-content asset paths.
- Test internal links under the local preview host.
- Check external embeds separately from theme rendering.
- Parse every changed XML content file.
- Confirm that the original theme and production configuration are unchanged.
- Build the web project:
dotnet build source/DasBlog.Web/DasBlog.Web.csprojPrepare a deployment manifest that separates:
- The complete new or changed
Themes/<theme-name>/folder - Changed content files and files under
content/binary - Intentional configuration changes
- The final theme activation step
Upload the theme and supporting content before setting it as active. Activate
it through /admin/themes or /admin/settings after confirming all required
files are present.
If you have additional questions or concerns, please submit an issue.