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

View file

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

View file

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

View file

@ -22,7 +22,7 @@
@inject EmailFactory Email @inject EmailFactory Email
@inject IEmailService EmailService @inject IEmailService EmailService
<PageTitle>@(TitlePrefix + (Article?.Title ?? Localizer["NotFound_Title"]))</PageTitle> <PageTitle>@((Article?.Title ?? Localizer["NotFound_Title"]) + TitlePostfix)</PageTitle>
@if (Article is not null) { @if (Article is not null) {
<HeadContent> <HeadContent>
@ -105,8 +105,8 @@
</ErrorBoundary> </ErrorBoundary>
@code { @code {
[CascadingParameter(Name = "TitlePrefix")] [CascadingParameter(Name = "TitlePostfix")]
private string TitlePrefix { get; set; } = default!; private string TitlePostfix { get; set; } = default!;
#region Route Parameters #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/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)"> <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> </HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"] + " | " + (Category?.Name ?? "Not Found"))</PageTitle> <PageTitle>@($"{Category?.Name ?? "Not Found"} {TitlePostfix}")</PageTitle>
@if (Category is null) { @if (Category is null) {
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["NotFound_Title"]</h1> <h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["NotFound_Title"]</h1>
@ -29,8 +32,8 @@
} }
@code { @code {
[CascadingParameter(Name = "TitlePrefix")] [CascadingParameter(Name = "TitlePostfix")]
private string TitlePrefix { get; set; } = default!; private string TitlePostfix { get; set; } = default!;
[Parameter] [Parameter]
public string CategoryName { get; set; } = string.Empty; public string CategoryName { get; set; } = string.Empty;

View file

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

View file

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

View file

@ -16,7 +16,7 @@
<meta name="robots" content="noindex,nofollow"> <meta name="robots" content="noindex,nofollow">
</HeadContent> </HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle> <PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<BoardComponent CenterContent="true"> <BoardComponent CenterContent="true">
<BoardCardComponent Heading="@Localizer["Title"]"> <BoardCardComponent Heading="@Localizer["Title"]">
@ -33,8 +33,8 @@
</BoardComponent> </BoardComponent>
@code { @code {
[CascadingParameter(Name = "TitlePrefix")] [CascadingParameter(Name = "TitlePostfix")]
private string TitlePrefix { get; set; } = default!; private string TitlePostfix { get; set; } = default!;
[Parameter, SupplyParameterFromQuery(Name = "user")] [Parameter, SupplyParameterFromQuery(Name = "user")]
public string? Id { get; set; } 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)" /> <link rel="canonical" href="@(new UriBuilder(Navigation.BaseUri) { Scheme = "https", Port = -1, Path = "/email/subscribe" }.Uri.AbsoluteUri)" />
</HeadContent> </HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle> <PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>
<BoardComponent CenterContent="true"> <BoardComponent CenterContent="true">
<BoardCardComponent Heading="@Localizer["Title"]"> <BoardCardComponent Heading="@Localizer["Title"]">
@ -44,8 +44,8 @@
</BoardComponent> </BoardComponent>
@code { @code {
[CascadingParameter(Name = "TitlePrefix")] [CascadingParameter(Name = "TitlePostfix")]
private string TitlePrefix { get; set; } = default!; private string TitlePostfix { get; set; } = default!;
[SupplyParameterFromForm(FormName = "email-signup")] [SupplyParameterFromForm(FormName = "email-signup")]
private InputModel Model { get; set; } = new(); private InputModel Model { get; set; } = new();

View file

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

View file

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

View file

@ -40,7 +40,7 @@
} }
</HeadContent> </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="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"> <div class="sm:col-span-2 flex flex-col">

View file

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

View file

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

View file

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

View file

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

View file

@ -6,10 +6,14 @@
@inject IDbContextFactory<ApplicationDbContext> ContextFactory @inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IStringLocalizer<Review> Localizer @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> <h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["Title"]</h1>
<ArticleCardList Articles="Articles" /> <ArticleCardList Articles="Articles" />
@code { @code {
[CascadingParameter(Name = "TitlePostfix")]
private string TitlePostfix { get; set; } = default!;
private List<Article> Articles { get; } = []; private List<Article> Articles { get; } = [];
protected override async Task OnInitializedAsync() { 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/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"> <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> </HeadContent>
<PageTitle>@(TitlePrefix + @Localizer["Title"] + " | " + (User?.FullName ?? Localizer["NotFound_Title"]))</PageTitle> <PageTitle>@($"{(User?.FullName ?? Localizer["NotFound_Title"])} {TitlePostfix}")</PageTitle>
@if (User is null) { @if (User is null) {
<h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["NotFound_Title"]</h1> <h1 class="text-3xl lg:text-5xl font-light mb-6 text-primary">@Localizer["NotFound_Title"]</h1>
@ -62,8 +65,8 @@
} }
@code { @code {
[CascadingParameter(Name = "TitlePrefix")] [CascadingParameter(Name = "TitlePostfix")]
private string TitlePrefix { get; set; } = default!; private string TitlePostfix { get; set; } = default!;
[CascadingParameter] [CascadingParameter]
public required HttpContext HttpContext { get; set; } public required HttpContext HttpContext { get; set; }

View file

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