JSON LD – Structured Data Markup

Why add structured data to a page?
Adding structured data can enable search results that are more engaging to users and might encourage them to interact more with your website, which are called rich results. Structured data is coded using in-page markup on the page that the information applies to. The structured data on the page describes the content of that page. Don’t create blank or empty pages just to hold structured data, and don’t add structured data about information that is not visible to the user, even if the information is accurate.

In SCA we are having a function called getJsonLd in the views which generated the Structured Data Markup, we can make use of it if we need to add or modify the data. Sample JSON-Ld function added bellow

getJsonLd: function getJsonLd(): JQuery.Deferred<JsonldWebPage> {
    if (Configuration.get('structureddatamarkup.type') !== 'JSON-LD' || !this.pages.length) {
        return jQuery.Deferred().resolve(null);
    }
    const jsonLdBreadcrumb: JsonldBreadcrumbList = {
        '@type': 'BreadcrumbList',
        itemListElement: []
    };

    const { origin } = window.location;
    const jsonLditemListElement: JsonldListItem[] = _.map(
        this.pages,
        (element: JSONObject, index: number): JsonldListItem => {
            return {
                '@type': 'ListItem',
                name: element.text.toString(),
                position: index + 1,
                item: origin + element.href
            };
        }
    );
    jsonLdBreadcrumb.itemListElement = jsonLditemListElement;

    // Get WebPage
    const jsonLd: JsonldWebPage = {
        '@type': 'WebPage',
        breadcrumb: jsonLdBreadcrumb
    };

    // Get Breadcrumb
    return jQuery.Deferred().resolve(jsonLd);
}

Leave a comment

Your email address will not be published. Required fields are marked *