Logo
Logo
  • Blazor CMS Home
  • Oqtane Tutorials
  • Blazor CMS Home
  • Oqtane Tutorials
Oqtane Tutorials
Oqtane Tutorials

Razor Page Service Tutorials

Tutorial Home › Razer Page Service
JSON-LD Headers for SEO
#6 Set Open-Graph headers for Social Media using the  IPageService
Work with the Context (Page, Site, etc.)

Set Open-Graph headers for Social Media using the IPageService

This page sets various open-graph headers. Look at the resulting output-source to see the effect.

Kit.Page gets the Page Service on newer Razors

This tutorial inherits from the Custom.Hybrid.Razor14 or the Custom.Hybrid.RazorTyped base class.

This allows us to use Kit.Page to access an IPageService without having to use GetService<IPageService>.

@inherits Custom.Hybrid.RazorTyped

@{
  // note: 'og:' is auto-prefixed if not given in the key

  Kit.Page.AddOpenGraph("title", "Demo of OpenGraph headers");
  Kit.Page.AddOpenGraph("type", "website");
}

Output is Invisible as it only affects the HTML Head

This sample modifies the HTML head, so it's not visible here. 

To see the effect, look at the source in the browser

 

JSON-LD Headers for SEO
#6 Set Open-Graph headers for Social Media using the  IPageService
Work with the Context (Page, Site, etc.)
  • 2sic internet solutions
  • Langäulistrasse 62, 9470 Buchs SG, Switzerland
  • +41 81 750 67 77
Login