• Home
  • Articles
  • API Documentation
  • Articles
  • Guide HtmlPage
Search Results for

    Show / Hide Table of Contents
    • Introduction
    • Fluent Tag API
    • Guide FavIcons
    • Guide HtmlPage
    • Change Log

    Razor Guide to HtmlPage v3.0

    Properties To Change Title, Description, Keywords

    1. HtmlPage.Description (get/set) - Read/Write the page description. v1.1

    2. HtmlPage.Keywords (get/set) - Read/Write the page keywords. v1.1

    3. HtmlPage.Title (get/set) - Read/Write the page title. v1.1

    Commands to Add Headers

    1. HtmlPage.AddMeta(name, content) - Adds a meta-tag with this name and content to the header. v1.1

    2. HtmlPage.AddJsonLd(...) create a JSON-LD (linked data) header see also google guideline and Schema.org. v1.1

      1. HtmlPage.AddToJsonLd(string) - uses a string, which should already be a valid json
      2. HtmlPage.AddToJsonLd(object) - will JSON-serialize whatever you pass into it. For now, we recommend using Dictionary<string, object> to prepare the data you want to add.
    3. HtmlPage.AddOpenGraph(property, content) add an open-graph tag to the header for facebook, twitter and co. v1.1

    4. HtmlPage.AddToHead(string) - Add anything to the <head> section of the page. The string should usually contain a meta, link or script tag. v1.1

    5. HtmlPage.AddIcon(path) add an icon (favicon) to the page v2.1

      1. ...AddIcon(path, rel: string, size: int, type: string) - all optional parameters to specify things like
        • rel: the rel-text, default is 'icon'. common terms are also 'shortcut icon' or 'apple-touch-icon
        • size: will be used in size='#x#' tag; only relevant if you want to provide multiple separate sizes
        • type: optional type, if not provided, will be auto-detected from known types or remain empty
    6. HtmlPage.AddIconSet(path) add a few icon headers to the page according to best practices v2.1
      1. ...AddIconSet(path, favicon: bool|string, rels: IEnumerable<string>, sizes: IEnumerable<int>) - all optional parameters to specify things like
        • favicon: boolean - auto-add a default favicon tag (or not)
        • favicon: string - use this url for the favicon tag
        • rels: list/array of rel-texts (a separate icon tag will be generated for each rel)
        • sizes: list/array of sizes (a separate icon tag will be generate for each size)
          note: if you supply rels and sizes, then all combinations of icon tags will be added
          note: you can't specify the type, as each one could be different - the auto-detection will take care of this for you

    Performance Optimizations

    The commands above are available for comfortable use. Internally, each command finds the page object and manipulates it. If you would like to optimize the code a bit, the GetPage() command gives you an object with the same features, but will run a few percent faster. So you can also do this:

    var p = HtmlPage.GetPage();
    p.Title = "...";
    p.Keywords = "...;
    
    • Improve this Doc
    In This Article
    • Properties To Change Title, Description, Keywords
    • Commands to Add Headers
    • Performance Optimizations
    Back to top Generated by DocFX