0
devmahmod created
I want to add meta tags and ld+json for cms page created by admin i'm workin with mvc core razor
2 Answer(s)
-
0
To add SEO meta tags and ld+json structured data to CMS pages created via the ABP CMS Kit (MVC Core Razor):
Extend the CMS Page Rendering:
- Override the Razor Page or View that renders your CMS Kit dynamic pages (typically under
/Pages/Cms/Pages/Detail.cshtml
or similar). - In this view, access the page's metadata (title, description, etc.) from the CMS Kit's page entity.
- Override the Razor Page or View that renders your CMS Kit dynamic pages (typically under
Add Meta Tags:
- In the
<head>
section of your layout or the specific page view, inject meta tags dynamically using the page's properties.
- In the
@model Volo.CmsKit.Public.Pages.PageDto @{ Layout = "_Layout"; } <head> <title>@Model.Title</title> <meta name="description" content="@Model.Description" /> <meta property="og:title" content="@Model.Title" /> <meta property="og:description" content="@Model.Description" /> <!-- Add more meta tags as needed --> </head>
- Add ld+json Structured Data:
- Insert a
<script type="application/ld+json">
block in the page, using Razor to serialize your data.
- Insert a
<script type="application/ld+json"> @{ var jsonLd = new { "@context" = "https://schema.org", "@type" = "Article", "headline" = Model.Title, "description" = Model.Description, "datePublished" = Model.CreationTime.ToString("yyyy-MM-dd"), "author" = new { "@type" = "Person", "name" = Model.CreatorName } }; var json = System.Text.Json.JsonSerializer.Serialize(jsonLd); } @Html.Raw(json) </script>
Custom Fields (Optional):
- If you need custom SEO fields (like custom meta description or keywords), extend the CMS Kit Page entity and admin UI to support these fields, then render them as above.
Reference:
- For more on customizing CMS Kit pages, see the official documentation and demo source code.
Sources:
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0