Skip to content

Commit 035aeb7

Browse files
authored
SEO optimized title (#819)
* SEO optimized title * Use title of root index.md as site name
1 parent 4d97d9e commit 035aeb7

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/Elastic.Markdown/Slices/HtmlWriter.cs

+3
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ private async Task<string> RenderLayout(MarkdownFile markdown, MarkdownDocument
9999
editUrl = $"https://github.com/elastic/{remote}/edit/{branch}/{path}";
100100
}
101101

102+
var siteName = DocumentationSet.Tree.Index?.Title ?? "Elastic Documentation";
103+
102104
var slice = Index.Create(new IndexViewModel
103105
{
106+
SiteName = siteName,
104107
DocSetName = DocumentationSet.Name,
105108
Title = markdown.Title ?? "[TITLE NOT SET]",
106109
Description = markdown.YamlFrontMatter?.Description ?? descriptionGenerator.GenerateDescription(document),

src/Elastic.Markdown/Slices/Index.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
public LayoutViewModel LayoutModel => new()
66
{
77
DocSetName = Model.DocSetName,
8-
Title = $"Elastic Documentation: {Model.Title}",
8+
Title = Model.CurrentDocument.Parent == null ? Model.Title : $"{Model.Title} | {Model.SiteName}",
99
Description = Model.Description,
1010
PageTocItems = Model.PageTocItems.Where(i => i is { Level: 2 or 3 }).ToList(),
1111
CurrentDocument = Model.CurrentDocument,

src/Elastic.Markdown/Slices/_ViewModels.cs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Elastic.Markdown.Slices;
1010

1111
public class IndexViewModel
1212
{
13+
public required string SiteName { get; init; }
1314
public required string DocSetName { get; init; }
1415
public required string Title { get; init; }
1516
public required string Description { get; init; }

0 commit comments

Comments
 (0)