Skip to main content
Home  › ... Razor

Razor Blade Tutorials

Tutorial HomeRazor.Blade

RazorBlade set Title, Description and other headers

This page sets the title, description, keywords and some manual tags to the header. Look at the resulting output-source to see the effect.

Source Code of this file

Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code

@inherits Custom.Hybrid.Razor12
@using ToSic.Razor.Blade;
@using ToSic.Sxc.Services;
<!-- unimportant stuff, hidden -->
RazorBlade set Title, Description and... <!-- unimportant stuff, hidden -->

@if(CmsContext.Platform.Name == "Oqtane") {
} else {
  // Note: this only works because we have @using ToSic.Razor.Blade on top
  // Again note that this only works in DNN and is not recommended any more - see warning
  var page = GetService<IPageService>();
  page.SetTitle("Title changed from the razor using Razor Blade! original: ");
  page.SetDescription("Learn to use Razor Blade");
  page.SetDescription("Learn to use Razor Blade");
  page.SetKeywords("Tutorial, Razor, Blade");
  page.SetKeywords("Tutorial, Razor, Blade");
  page.AddToHead("<meta xyz>");
  page.AddMeta("somename", "somevalue");

<!-- unimportant stuff, hidden -->