Skip to content

SEO optimized title #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Elastic.Markdown/Slices/HtmlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ private async Task<string> RenderLayout(MarkdownFile markdown, MarkdownDocument
editUrl = $"https://github.com/elastic/{remote}/edit/{branch}/{path}";
}

var siteName = DocumentationSet.Tree.Index?.Title ?? "Elastic Documentation";

var slice = Index.Create(new IndexViewModel
{
SiteName = siteName,
DocSetName = DocumentationSet.Name,
Title = markdown.Title ?? "[TITLE NOT SET]",
Description = markdown.YamlFrontMatter?.Description ?? descriptionGenerator.GenerateDescription(document),
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Markdown/Slices/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public LayoutViewModel LayoutModel => new()
{
DocSetName = Model.DocSetName,
Title = $"Elastic Documentation: {Model.Title}",
Title = Model.CurrentDocument.Parent == null ? Model.Title : $"{Model.Title} | {Model.SiteName}",
Description = Model.Description,
PageTocItems = Model.PageTocItems.Where(i => i is { Level: 2 or 3 }).ToList(),
CurrentDocument = Model.CurrentDocument,
Expand Down
1 change: 1 addition & 0 deletions src/Elastic.Markdown/Slices/_ViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Elastic.Markdown.Slices;

public class IndexViewModel
{
public required string SiteName { get; init; }
public required string DocSetName { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
Expand Down
Loading