Improved SEO through better page titles (this mostly affects google)

This commit is contained in:
Mia Rose Winter 2024-03-17 13:46:16 +01:00
parent 3bf0f4e6df
commit 0f9970722f
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
19 changed files with 64 additions and 44 deletions

View file

@ -17,7 +17,7 @@
@inject IStringLocalizer<Admin> Localizer
@inject IDistributedCache WaveDistributedCache
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<StatusMessage Message="@Message" />
@ -40,8 +40,8 @@
</EditForm>
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[CascadingParameter]
private HttpContext HttpContext { get; set; } = default!;

View file

@ -9,7 +9,7 @@
@inject ILogger<ArticleDeleteConfirm> Logger
@inject IStringLocalizer<ArticleView> Localizer
<PageTitle>@(TitlePrefix + (Article is not null ? Localizer["Delete_Title"] : Localizer["NotFound_Title"]))</PageTitle>
<PageTitle>@((Article is not null ? Localizer["Delete_Title"] : Localizer["NotFound_Title"]) + TitlePostfix)</PageTitle>
@if (Article is not null) {
<BoardComponent CenterContent="true">
@ -34,8 +34,8 @@
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[Parameter]
public Guid Id { get; set; }

View file

@ -10,7 +10,7 @@
@inject UserManager<ApplicationUser> UserManager
@inject IStringLocalizer<ArticleEditor> Localizer
<PageTitle>@(TitlePrefix + Localizer["EditorTitle"])</PageTitle>
<PageTitle>@(Localizer["EditorTitle"] + TitlePostfix)</PageTitle>
@if (User is null) {
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["EditorTitle"]</h1>
@ -33,8 +33,8 @@
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[CascadingParameter]
private Task<AuthenticationState>? AuthenticationState { get; set; }

View file

@ -22,7 +22,7 @@
@inject EmailFactory Email
@inject IEmailService EmailService
<PageTitle>@(TitlePrefix + (Article?.Title ?? Localizer["NotFound_Title"]))</PageTitle>
<PageTitle>@((Article?.Title ?? Localizer["NotFound_Title"]) + TitlePostfix)</PageTitle>
@if (Article is not null) {
<HeadContent>
@ -105,8 +105,8 @@
</ErrorBoundary>
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
#region Route Parameters

View file

@ -14,9 +14,12 @@
<link rel="alternate" type="application/rss+xml" title="RSS Feed on @Customizations.Value.AppName | @Category.Name" href="/rss/rss.xml?category=@WebUtility.UrlEncode(Category.Name)">
<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed on @Customizations.Value.AppName | @Category.Name" href="/rss/atom.xml?category=@WebUtility.UrlEncode(Category.Name)">
}
@if (Category is null) {
<meta name="robots" content="noindex">
}
</HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"] + " | " + (Category?.Name ?? "Not Found"))</PageTitle>
<PageTitle>@($"{Category?.Name ?? "Not Found"} {TitlePostfix}")</PageTitle>
@if (Category is null) {
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["NotFound_Title"]</h1>
@ -29,8 +32,8 @@
}
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[Parameter]
public string CategoryName { get; set; } = string.Empty;

View file

@ -8,7 +8,7 @@
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IStringLocalizer<Deleted> Localizer
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
@ -23,8 +23,8 @@
</ArticleCardList>
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
private List<Article> Articles { get; } = [];

View file

@ -8,10 +8,14 @@
@inject UserManager<ApplicationUser> UserManager
@inject IStringLocalizer<Drafts> Localizer
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
<ArticleCardList Articles="Articles" />
@code {
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[CascadingParameter]
private HttpContext HttpContext { get; set; } = default!;

View file

@ -16,7 +16,7 @@
<meta name="robots" content="noindex,nofollow">
</HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<BoardComponent CenterContent="true">
<BoardCardComponent Heading="@Localizer["Title"]">
@ -33,8 +33,8 @@
</BoardComponent>
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[Parameter, SupplyParameterFromQuery(Name = "user")]
public string? Id { get; set; }

View file

@ -22,7 +22,7 @@
<link rel="canonical" href="@(new UriBuilder(Navigation.BaseUri) { Scheme = "https", Port = -1, Path = "/email/subscribe" }.Uri.AbsoluteUri)" />
</HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<BoardComponent CenterContent="true">
<BoardCardComponent Heading="@Localizer["Title"]">
@ -44,8 +44,8 @@
</BoardComponent>
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[SupplyParameterFromForm(FormName = "email-signup")]
private InputModel Model { get; set; } = new();

View file

@ -3,7 +3,7 @@
@inject IStringLocalizer<Error> Localizer
<PageTitle>@Localizer["Title"]</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light text-primary">@Localizer["Title"]</h1>
@ -16,6 +16,8 @@
}
@code {
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[CascadingParameter]
private HttpContext? HttpContext { get; set; }

View file

@ -6,10 +6,15 @@
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IStringLocalizer<Future> Localizer
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
<ArticleCardList Articles="Articles" />
@code {
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
private List<Article> Articles { get; } = [];
protected override async Task OnInitializedAsync() {

View file

@ -40,7 +40,7 @@
}
</HeadContent>
<PageTitle>@(TitlePrefix[..^3])</PageTitle>
<PageTitle>@(Customizations.Value.AppName ?? "Wave")</PageTitle>
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 xl:grid-rows-4 gap-4">
<div class="sm:col-span-2 flex flex-col">

View file

@ -12,7 +12,7 @@
@inject IMessageDisplay Message
@inject IStringLocalizer<ManageApi> Localizer
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
@ -81,8 +81,8 @@
</section>
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[SupplyParameterFromForm(FormName = "NewApiKey")]
private InputModel Model { get; set; } = new();

View file

@ -11,7 +11,7 @@
@inject IStringLocalizer<ManageCategories> Localizer
@inject IMessageDisplay Message
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<ModalComponent Id="@ModalId">
<ChildContent>
@ -67,8 +67,8 @@ bg-error text-error-content
</ul>
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
private InputModel Model { get; set; } = new();
private List<Category> Categories { get; } = new();

View file

@ -13,7 +13,7 @@
@inject IStringLocalizer<ManageUsers> Localizer
@inject IMessageDisplay Toast
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
@ -57,8 +57,8 @@
</section>
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
private string ModalId { get; } = "UserDialog";
[CascadingParameter]

View file

@ -8,7 +8,7 @@
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IOptions<Features> Features
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
@ -56,8 +56,8 @@
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
private IReadOnlyList<EmailNewsletter> Newsletters { get; set; } = [];
private int SubscribersTotal { get; set; }

View file

@ -6,10 +6,14 @@
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IStringLocalizer<Review> Localizer
<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
<ArticleCardList Articles="Articles" />
@code {
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
private List<Article> Articles { get; } = [];
protected override async Task OnInitializedAsync() {

View file

@ -15,9 +15,12 @@
<link rel="alternate" type="application/rss+xml" title="RSS Feed on @Customizations.Value.AppName | User @User.FullName" href="/rss/rss.xml?author=@User.Id">
<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed on @Customizations.Value.AppName | User @User.FullName" href="/rss/atom.xml?author=@User.Id">
}
@if (User is null) {
<meta name="robots" content="noindex">
}
</HeadContent>
<PageTitle>@(TitlePrefix + @Localizer["Title"] + " | " + (User?.FullName ?? Localizer["NotFound_Title"]))</PageTitle>
<PageTitle>@($"{(User?.FullName ?? Localizer["NotFound_Title"])} {TitlePostfix}")</PageTitle>
@if (User is null) {
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["NotFound_Title"]</h1>
@ -62,8 +65,8 @@
}
@code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
[CascadingParameter]
public required HttpContext HttpContext { get; set; }

View file

@ -173,8 +173,7 @@
builder.Services.Configure<Features>(builder.Configuration.GetSection(nameof(Features)));
builder.Services.Configure<Customization>(builder.Configuration.GetSection(nameof(Customization)));
builder.Services.AddCascadingValue("TitlePrefix",
sf => (sf.GetService<IOptions<Customization>>()?.Value.AppName ?? "Wave") + " - ");
builder.Services.AddCascadingValue("TitlePostfix", sf => " | " + (sf.GetService<IOptions<Customization>>()?.Value.AppName ?? "Wave"));
var emailConfig = builder.Configuration.GetSection("Email").Get<EmailConfiguration>();
builder.Services.Configure<EmailConfiguration>(builder.Configuration.GetSection("Email"));