docs/en/modules/blogging.md
//[doc-seo]
{
"Description": "Learn how to install and configure the standalone ABP Blogging module, including its MVC UI, routes, permissions, files and database providers."
}
The Blogging module is a free and open-source application module for creating one or more blogs. It provides an MVC / Razor Pages user interface, application services, HTTP APIs and Entity Framework Core and MongoDB integrations for blogs, posts, tags, comments and member profiles.
This page documents the standalone
Volo.Bloggingmodule. CMS Kit: Blogging is a different feature family with different entities, configuration and UI.
Use the ABP CLI to add the module to an existing solution:
abp add-module Volo.Blogging
The command adds the module packages and dependencies to the compatible projects in your solution. Apply the generated database migration after adding the module.
The source code of this module is available in the ABP repository. It is licensed with MIT, so you can use and customize it.
The module provides two MVC / Razor Pages surfaces:
When the application has one blog, the blog index redirects directly to that blog. With multiple blogs, the index displays the available blogs.
Creating a post makes it available to the public list and reading APIs immediately. The standalone module does not add a draft, review or scheduled-publication state. If a post URL is already used in the same blog, the application service appends a generated suffix and returns the resulting URL.
Tags are entered with a post. The application service normalizes tag names to lowercase, removes duplicates and maintains their usage counts.
The module keeps a local BlogUser record for post and comment authors. It uses ABP's user lookup and synchronization infrastructure to obtain Identity user data. The public member page lists an active user's posts and profile information; the current user can edit the Blogging-specific fields on their own profile.
The administration menu is visible with the Blogging.Blog.Management permission. Blog operations use separate child permissions:
Blogging.Blog.CreateBlogging.Blog.UpdateBlogging.Blog.DeleteBlogging.Blog.ClearCachePost creation, update and deletion require Blogging.Post.Create, Blogging.Post.Update and Blogging.Post.Delete, respectively.
Any authenticated user can create a comment. A comment can be updated or deleted by its creator or by a user with Blogging.Comment.Update or Blogging.Comment.Delete.
See the Authorization documentation to learn how to grant permissions to roles and users.
BloggingUrlOptions.RoutePrefix controls the public URL prefix. Its default value produces URLs under /blog/. The following example moves the public blog under /articles/ and enables single-blog mode for the blog whose short name is engineering:
Configure<BloggingUrlOptions>(options =>
{
options.RoutePrefix = "articles";
options.SingleBlogMode.Enabled = true;
options.SingleBlogMode.BlogName = "engineering";
});
Single-blog mode removes the blog short-name segment from post URLs. If the application contains multiple blogs, set SingleBlogMode.BlogName to the short name of the blog to expose. If it contains exactly one blog, the module can select it without setting BlogName.
Set RoutePrefix to an empty string to serve the blog from /. In this mode the route constraint uses IgnoredPaths to avoid capturing other top-level application routes. The module already adds its framework endpoints, bundle folder and member route; add application-specific top-level paths when needed:
Configure<BloggingUrlOptions>(options =>
{
options.RoutePrefix = "";
options.IgnoredPaths.Add("health");
});
Post images are saved through the BLOB Storing system in the blogging-files container. Configure a BLOB provider for this container as you would for any other typed container.
The upload service accepts JPEG, PNG, GIF and BMP images. The maximum file size is 5 MiB by default. BloggingWebConsts.FileUploading.MaxFileSize is a process-wide static value, so set it once during application startup, before the application begins accepting uploads:
BloggingWebConsts.FileUploading.MaxFileSize = 10 * 1024 * 1024;
The post page emits Twitter card metadata. Configure the site handle with BloggingTwitterOptions:
Configure<BloggingTwitterOptions>(options =>
{
options.Site = "@myblog";
});
The time-ordered post list is cached per blog for one hour. Creating, updating or deleting posts through IPostAppService invalidates that cache within the current unit of work. The blog administration page also provides a Clear Cache action to users with the Blogging.Blog.ClearCache permission.
If custom code changes posts directly through IPostRepository, publish the module's PostChangedEvent with the affected blog ID. The built-in event handler then removes that blog's cached list as part of the current unit of work.
The main aggregates are:
Blog: A named blog identified in public URLs by its short name.Post: Markdown content, cover image, URL, tags and read count for a blog.Comment: A comment or direct reply attached to a post.Tag: A normalized tag and its usage count within a blog.BlogUser: The module-local representation of an Identity user and Blogging profile.The public application-service contracts are IBlogAppService, IPostAppService, ICommentAppService, ITagAppService and IFileAppService. IBlogManagementAppService provides blog administration operations.
The HTTP API uses the Blogging remote-service name for public operations and BloggingAdmin for administration operations. Add BloggingHttpApiClientModule or BloggingAdminHttpApiClientModule to a client application when these services run remotely.
The module uses Blogging as its connection string name and falls back to Default when that connection is not configured. See the Connection Strings documentation.
Tables and collections use the Blg prefix by default. Set AbpBloggingDbProperties.DbTablePrefix and, for providers that support schemas, AbpBloggingDbProperties.DbSchema before the database model is created:
AbpBloggingDbProperties.DbTablePrefix = "MyBlog";
AbpBloggingDbProperties.DbSchema = "blogging";
The Entity Framework Core provider uses these tables:
BlgUsersBlgBlogsBlgPostsBlgCommentsBlgTagsBlgPostTagsCall ConfigureBlogging() from your migration DbContext when integrating the module manually.
The MongoDB provider uses these collections:
BlgUsersBlgBlogsBlgPostsBlgCommentsBlgTagsPost-tag links are stored with the post documents, so MongoDB does not use a separate BlgPostTags collection.