How to use HeadContent to replace meta tags in Blazor Wasm not-hosted - seo

I'm on .NET6 and I have a Blazor Wasm application that is hosted as an Azure Static Website.
I understand how to add meta tags like description and keywords using
<PageTitle>Index</PageTitle>
<HeadContent>
<meta name="description" content="Blazor WASM index page.">
</HeadContent>
But I want to add the needed meta tags to index.html and let the component overwrite them.
Now the component is adding them. Resulting in duplicate meta tags.
This line in my Program.cs is responsible for that:
builder.RootComponents.Add<HeadOutlet>("head::after");
The documentation says it will add the meta tags at the end, which it does. How to make it replace any existing meta tags?
The reason I want this is so every page will at least have a full set of meta tags and I assume it is also better for SEO.

I found that the <HeadContent> will only overwrite tags in other <HeadContent> components, it will not overwrite tags in the index.html <head>

Related

Can I put Open Graph tags out of the head tag of my page?

I am talking about the Open Graph tag here. Can I put the og meta tag anywhere on the page?
I want to use my detail page image for the og tag, the easiest solution is putting the og:image tag in the body of my page.
Open Graph meta tags should always be nested between <head> tags.
To turn your web pages into graph objects, you need to add basic
metadata to your page. We've based the initial version of the protocol
on RDFa which means that you'll place additional <meta> tags in the
<head> of your web page.
http://ogp.me/#metadata
Additionally, keep in mind that order of the tags matters, especially when dealing with array tags (which includes og:image).
Open Graph Tag should be always always be placed on header tag until knowledge goes.. People please correct me if I am wrong..

overwrite X-UA-Compatible meta in SharePoint 2010

I am working on SharePoint 2010 and I want to use
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
for a specific page.
The master page is setting it to "IE=8" which doesn't allow me to use box-shadow in CSS e.g.
I don't have access to the masterpage to change it.
Also I have read that changing that meta in master page is not recommended as it might cause issues with other things like calendars or whatever.
So my Q is: is there any way of overwriting the X-UA-Compatible meta tag in a simple page (.aspx)?
Among the ways to change the compatibility mode for page two of them seems promising:
Via X-UA-compatible HTTP header: The web server has requested a legacy document mode via an HTTP header.
Via X-UA-compatible meta tag: The webpage developer used a meta tag to specify a legacy document mode.
SharePoint 2010's default master page hardcodes X-UA-Compatible meta tag, and meta tag takes precedence over HTTP header, so this can't be done on HTTP level. This leaves us with the second option.
It seems that the first X-UA-compatible meta tag encountered on the page is used by IE (although it's ambiguous in different articles and missing in MSDN documentation). If you write SharePoint UserControl or WebPart you might add this code e.g. in Page_Load() method to add this header as the first one:
HtmlMeta metaEdgeIE = new HtmlMeta();
metaEdgeIE.HttpEquiv = "X-UA-Compatible";
metaEdgeIE.Content = "IE=EDGE";
Page.Header.Controls.AddAt(0, metaEdgeIE);
where HtmlMeta comes from System.Web.UI.WebControls namespace.
By iterating through Page.Header.Controls you could probably also find and remove the meta tag added by default by SharePoint, although the code above seems enough to trigger Edge mode in IE11.
If you can edit the master page and only want to change the compatibility for particular pages you can take a similar approach to buli (thanks) but overwrite the existing Content of the meta tag.
For your meta tag in the master page, give it an id and runat server
<meta id="metaIE" runat="server" http-equiv="X-UA-Compatible" content="IE=edge">
In your page load, find the control from master, cast to HtmlMeta and change the Content
Dim metaIE = DirectCast(Master.FindControl("metaIE"), HtmlMeta)
metaIE.Content = "IE=10"

Can meta tag description be declared dynamically in a web page

I have a dynamic page, where the contents and title will change based on the parameters in the URL. I want the same to be done for meta tag description. As I don't have a sound knowledge of SEO, I don't know whether it will be valid or not.
Say suppose URL contains word "test"
I will do,
if("test" is present)
{
<title>test</test>
<meta decription="test"/>
}
else
{
<title>test1</test>
<meta decription="test1"/>
}
Can I do this? Does giving two meta tag descriptions for same page work.
It is best practice to have different, on the page content based values of the title element and the meta description for each web page. It is not forbidden by the the HTML5 specification to have multiple <meta name="description" content="YOUR DESCRIPTION"> elements but I would guess that search engines process only the first appearance of the element. So my recommendation would be use one <meta name="description" content="YOUR DESCRIPTION"> element for each page.
As long as you code it server-side (eg in PHP) when the page is generated rather than client-side (javascript) after the page has loaded, then it will be fine. That's how most CMS systems work already.
Done server-side, only one of the description tags will actually appear in the code Google see.
Done client-side, it is likely that they will see no description at all as I don't think many search engines render javascript.

Use search engine meta tag outside of the <head> section

I'm using a meta tag to restrict access to specific parts of a website. The problem is that I'm using a CMS and I can only insert the <meta> tag inside the <body>, because the <head> sections is part of the universally used main template. Dose the <meta> tag still work outside the <head> section?
You can accomplish the same effect as that meta tag using an HTTP header. The X-Robots-Tag can be set in an .htaccess file and will do the exact same thing as the meta tag. If your CMS doesn't support it you can always add it manually and it won't be affected by the CMS creates pages at all.

meta tags in .net framework 4.0 in pages base on master and content pages

where should i put meta tags in .net framework 4.0 in pages base on master and content pages?
mean in two below purposes :
1 - for each content page separately
2 - for all pages in master page
is there any property in master or content pages for setting meta tags and title ?(i could n't find them)
If there are meta tags that should be on ALL pages, you put it in the <head> section of your master page, just like you would a normal HTML page. There's no property for it because it's not a server-side property, you just put it in your page.
For individual meta tags that are different for each content page, add a new <ContentPlaceHolder> in the <head> of your master page. That will let you define the actual content on each page.