Making a Blog with C# - Part 6
SEO
I wanted to make links to my blog posts more accurate, so I needed to add some <meta>
tags
to provide title, description and tags to the websites displaying links.
I wanted to use the data I already have for rendering blog post cards on the front page, so I figured I'd make a component for it:
This uses the built-in <PageTitle>
and <HeadContent>
Component to update title and metadata respectively.
The meta tags that start in og
helps sites like Twitter and Facebook display the information in a nice way.
To make use of the new MetadataComponent
, I first removed the title and meta tags from Index.razor
,
and replaced it with this:
Usage in Index.razor
The defaults are defined in a separate file:
To set it up for BlogPosts, I did the following in BlogPostComponent.razor
:
File trimmed for brevity
Summary
We've seen that adding SEO metadata to Blazor Server is a breeze using the built in <PageTitle>
and <HeadContent
components.
See the code
Pull Request implementing the changes in this post
The state of the blog
Front page
This post