Skip to content

Add documentation on influencing the HTML head from Blazor #19265

Closed
@MackinnonBuck

Description

@MackinnonBuck

[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 in Title. For Meta and Link, 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 the Title that was most recently rendered.
  • Even if there are multiple Meta components being rendered with identical attributes, there will be exactly one meta tag per Meta component (in other words, two Meta components can't refer to the same meta tag). This also applies to Link components.
  • Changes to parameters of existing Meta components will be reflected by its meta tag (also applies to Link).
  • Disposing a Meta component removes its meta tag from the DOM (also applies to Link).

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.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions