Closed
Description
[EDIT by guardrex to add the metadata]
A new preview8 feature enables influencing the HTML head
element from Blazor.
When rendered, the Title
, Link
, and Meta
components add or update data in the HTML head.
Usage example:
@using Microsoft.AspNetCore.Components.Web.Extensions
<Title Value="New document title" />
<Link rel="stylesheet" href="styles.css" />
<Meta name="description" content="Influencing the head from a Blazor component" />
Here are a few notes about the feature:
- Server-side prerendering is supported.
- Only the
Value
parameter is valid inTitle
. ForMeta
andLink
, all provided parameters will be reflected in the DOM. - When there are multiple
Title
components being rendered, the title of the page will reflect that of theTitle
that was most recently rendered. - Even if there are multiple
Meta
components being rendered with identical attributes, there will be exactly onemeta
tag perMeta
component (in other words, twoMeta
components can't refer to the samemeta
tag). This also applies toLink
components. - Changes to parameters of existing
Meta
components will be reflected by itsmeta
tag (also applies toLink
). - Disposing a
Meta
component removes itsmeta
tag from the DOM (also applies toLink
).
Let me know if you would like additional information.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 81a32115-33f8-7d06-aaf0-b8ce918b5527
- Version Independent ID: 31ad18df-1904-bbdd-cfed-8d0d0267c10e
- Content: Create and use ASP.NET Core Razor components
- Content Source: aspnetcore/blazor/components/index.md
- Product: aspnet-core
- Technology: aspnetcore-blazor
- GitHub Login: @guardrex
- Microsoft Alias: riande
Metadata
Metadata
Assignees
Type
Projects
Status
Done