-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Blazor <head> components #25705
Comments
Thanks for contacting us. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Thanks for contacting us. |
Any updates on this?! |
@araxemy I agree that this is very crucial. Implementation is not time consuming but API design is what takes time. It is important to the Asp.net team when implementing a feature to make sure that the design of the code is as close as it could be to the standards carried out through out the project making sure it is easily maintainable and scalable. |
I've published an example of how this might be done. I've used an approach similar to this in other apps and can confirm it updated the page title in a way that ensured it was picked up correctly on client-side navigation events tracked by web analytics libraries (e.g. Application Insights) so that the correct page title is tracked when a page view is reported. This approach uses a <PageHead>
<meta name="author" content="This guy right here" />
<meta name="keywords" content="some keywords yo" />
<meta name="abstract" content="what even is a page anyway?" />
<title>Home</title>
<link href="css/home.css" rel="stylesheet" />
</PageHead> Any feedback welcome! |
Sorry to late (I could not notice this thread for over a half year), and sorry to bother you, but please let me introduce the workaround for managing page head content that we can use today. The workaround is the "Toolbelt Blazor Head Element" NuGet packages that I built. I released the first version of those packages two years ago when the Blazor was the preview version. Those packages allow us to add or change a document title, link, meta elements in a page head with Blazor component syntax. ...
<!-- This is "Pages/Counter.razor" -->
<Title>Counter (@currentCount) - My App</Title>
... Those packages can work fine both Blazor WebAssembly and Blazor Server. Those packages are used in the "Powered 4 TV" site, the "MudBlazor" document site, etc. Of course, ASP.NET Core built-in support and a standardizing way to managing page head content should be welcome, and I think so too. I just wanted to notify somebody that there is a "workaround". |
Completed in #34218. |
…34518) ## Description This PR introduces a way for developers to modify the HTML `<head>` contents from Blazor. ## Customer Impact With this feature, customers will be able to easily * Modify the document title (tab name). * Add link previews for links to their web app. * Optimize their website for SEO. * Dynamically change style sheets (e.g. switch between light and dark modes). Other SPA frameworks have third-party libraries enabling `<head>` modification, so this change makes Blazor an even more viable alternative. Addresses #25705
Summary
Through some experimentation, it was discovered that there is opportunity for improvement with the Blazor
Head
components (Title
,Link
, andMeta
). This issue is for tracking the items that need to be addressed regarding these components.Details
Following are the items that need to be addressed:
<Title>
to render theChildContent
as the document title and remove theValue
parameter. This is more consistent with the HTML<title>
element.<head>
changes apply before page navigation events so they can be picked up properly by web analytics, etc.Head
components. The completion of Adding partial namespaces in Blazor's razor markup #22194 might be an acceptable solution, but we might want an additional fix that covers all use cases.The text was updated successfully, but these errors were encountered: