Improved SEO with canonical, noindex and better homepage title

This commit is contained in:
Mia Rose Winter 2024-03-17 13:24:30 +01:00
parent 00a14727c3
commit 31cec9327f
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
6 changed files with 24 additions and 2 deletions

View file

@ -10,9 +10,11 @@
@inject NavigationManager NavigationManager
@inject IdentityRedirectManager RedirectManager
@inject IStringLocalizer<Login> Localizer
@inject NavigationManager Navigation
<HeadContent>
<meta name="robots" content="nofollow">
<link rel="canonical" href="@(new UriBuilder(Navigation.BaseUri) { Scheme = "https", Port = -1, Path = "/account/login" }.Uri.AbsoluteUri)" />
</HeadContent>
<PageTitle>@Localizer["Title"]</PageTitle>

View file

@ -15,9 +15,11 @@
@inject NavigationManager NavigationManager
@inject IdentityRedirectManager RedirectManager
@inject IStringLocalizer<Register> Localizer
@inject NavigationManager Navigation
<HeadContent>
<meta name="robots" content="nofollow">
<link rel="canonical" href="@(new UriBuilder(Navigation.BaseUri) { Scheme = "https", Port = -1, Path = "/account/register" }.Uri.AbsoluteUri)" />
</HeadContent>
<PageTitle>@Localizer["Title"]</PageTitle>

View file

@ -45,6 +45,10 @@
<link rel="alternate" type="application/rss+xml" title="RSS Feed on @Customizations.Value.AppName" href="/rss/rss.xml">
<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed on @Customizations.Value.AppName" href="/rss/atom.xml">
}
@if (Article is not null) {
<link rel="canonical" href="@ArticleUtilities.GenerateArticleLink(Article, new Uri(Navigation.BaseUri))" />
}
</HeadContent>
}

View file

@ -15,6 +15,12 @@
@inject IEmailService EmailService
@inject EmailFactory Email
@inject IMessageDisplay Messages
@inject NavigationManager Navigation
<HeadContent>
<meta name="robots" content="nofollow">
<link rel="canonical" href="@(new UriBuilder(Navigation.BaseUri) { Scheme = "https", Port = -1, Path = "/email/subscribe" }.Uri.AbsoluteUri)" />
</HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>

View file

@ -30,9 +30,17 @@
<link rel="alternate" type="application/rss+xml" title="RSS Feed on @Customizations.Value.AppName" href="/rss/rss.xml">
<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed on @Customizations.Value.AppName" href="/rss/atom.xml">
}
@if (Page > TotalPages) {
<meta name="robots" content="noindex">
} else if (Page > 0) {
<link rel="canonical" href="@(new UriBuilder(Navigation.BaseUri) { Scheme = "https", Query = "?page=" + Page, Port = -1 }.Uri.AbsoluteUri)" />
} else {
<link rel="canonical" href="@(new UriBuilder(Navigation.BaseUri) { Scheme = "https", Port = -1 }.Uri.AbsoluteUri)" />
}
</HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<PageTitle>@(TitlePrefix[..^3])</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

@ -16,6 +16,6 @@ public static class ArticleUtilities {
if (host is null) return link;
return new Uri(host, link).AbsoluteUri;
return new UriBuilder("https", host.Host, -1, link).Uri.AbsoluteUri;
}
}