Published on

Adding MetaProperties like OpenGraph to ActionResult routes

Authors

Dynamically created pages through custom routes in Sitefinity are pretty great. But the problem always is that they then have bad SEO because they inherit their page meta from the ACTUAL page the controller\widget is sitting on (to generate this route).

This is the official the way to set your OpenGraph or Meta Title\Meta Description properties on your custom routes.

var description = "Some content description";


MetadataModel metadataProperties = new MetadataModel()
{
    MetaTitle = "My widget page title",
    MetaDescription = description,
    OpenGraphDescription = description,
    Url = Util.CurrentHttpContext.Request.Url.ToString()
};


this.ViewBag.Metadata = metadataProperties;

Big thanks to Stanislav Velikov (Progress Software) for the assist, this doesn’t seem to be anywhere in the KB.