Creating a Json Schema for your website

Probably Elementary but this will create a pretty robust json schema. That passes schema.org. It’s probably not all correct. But I am a novice. It will help with other websites being able to read your site.
Also please note i have a field in my front matter on pages called

practice_area: Divorce

to display all the pages listed that have that parameter.

it is being called from here.

{{- $pages := where .Site.RegularPages "Params.practice_area" "Divorce" -}}

So it displays all the pages in an offer catalog. Please check the offer catalog below in the validator.schema.org

I don’t particularly like working with attorneys. It makes my soul feel empty.

https://validator.schema.org/#url=https%3A%2F%2Fwww.sevenslegal.com

Params.Toml

########################### Default parameters ######################
disableHugoGeneratorInject = "false"
logo = "/images/sevens-legal-logo.svg"
logo_png = "/images/sevens-legal-logo.png"
backgroundint = "/images/backgrounds/page-title.webp" 
attorney_photo = "/images/Samantha-Greene-2.jpg"
logo_width = "180px"
googleAnalytics = "G-1T9T4W3EQD"
logo_footer = "/images/sevens-legal-logo.svg"
favicon = "/images/favicon.svg"
lawFirmName = "Sevens Legal, APC"
founder ="Samantha Greene"
foundinglocation = "San Diego, California"
slogan = "San Diego Criminal Lawyer"
# Schema
avvo = "https://www.avvo.com/attorneys/92103-ca-samantha-greene-297353.html"
# top header
top_header = false
enableRobotsTXT = true
# Meta data
description = "Sevens Legal, APC is San Diego's premier criminal defense lawyers. We offer a free consultation. Call us today at (619) 430-2355."
author = "Samantha Greene"
# contact info
address = "3555 Fourth Ave, San Diego CA 92103"
phoneicon = "/images/icons/phone.svg"
mappinicon ="/images/icons/mappin.svg"
location1 = "San Diego"
mobile = "(619) 430-2355"
mapImage = "/images/3555-fourth-ave-san-diego-92103.jpg"
mapImagewebp ="/images/3555-fourth-ave-san-diego-92103.webp"
address2 = "500 La Terraza Blvd. Suite 150, Escondido, CA 92025"
mobile2 = "(760) 973-4005"
location2 = "Escondido"
site-directions-long1 ="https://www.google.com/maps/dir/33.8952192,-118.4038912/3555+fourth+ave/@33.3973946,-118.2969982,9z/data=!3m1!4b1!4m9!4m8!1m1!4e1!1m5!1m1!1s0x80d9552574d2cd71:0xbb4c889ccb39704b!2m2!1d-117.1613045!2d32.7425026?entry=ttu"
site-directions-long2 ="https://www.google.com/maps/place/Sevens+Legal+Criminal+Lawyers/@33.1125565,-117.0980729,17z/data=!3m1!4b1!4m6!3m5!1s0x80dbf48e93d388db:0x9d661379896854be!8m2!3d33.1125565!4d-117.0958842!16s%2Fg%2F11c60b21yq?entry=ttu"
mapImage2 = "/images/500-la-terraza-blvd-suite-150-escondido-ca-92025.jpg"
mapImagewebp2 = "/images/500-la-terraza-blvd-suite-150-escondido-ca-92025.jpg"
calltrackingCode = "30789.tctm.co/t.js"
contact_picture = "/wp-content/uploads/2019/02/619-Divorce-Fav-320-320.gif"
mapcover = "/wp-content/uploads/2015/12/619-DIVORCE-BG.jpg"
mapcover_webp ="/wp-content/uploads/2015/12/619-DIVORCE-BG.webp"
# contact form action
# page sidebar quick contact form
quick_contact = true
# search
search = false
[markup]
  [markup.tableOfContents]
    startLevel = 2
    endLevel = 5
    ordered = false

# Preloader
[preloader]
enable = false
preloader = "" # use jpg, png, svg or gif format.

# Navigation button
[navigation_button]
enable = true
label = "(619) 430-2355"

# Subscription
[subscription]
enable = false

# google map
[gmap]
enable = false
map_latitude = '32.742490'
map_longitude = '-117.161220'
map_latitude2 =""
map_longitude2 =""
map_marker = "images/marker.png"
map_marker_name = "Sevens Legal, APC"

########################### social icon ############################
[[social]]
icon = "/images/icons/facebook.svg"
link = "https://www.facebook.com/sevenslegalapc/"
title = "Facebook Page"

[[social]]
icon = "/images/icons/linkedin.svg"
link = "https://www.linkedin.com/company/sevens-legal"
title = "Linkedin Page"

[[social]]
icon = "/images/icons/instagram.svg"
link = "https://instagram.com/sevenslegal/"
title = "Instagram Page"


-------------------------------------------------

Json Partial

<script type='application/ld+json'> 
    {
        "@context": "https://schema.org",
        "@type": "WebPage",
        "additionalType":["{{.Site.Params.additionalType1}}","{{.Site.Params.additionalType2}}"],
        "mainEntity": {
        "@type": "LegalService",
        "name": "{{ .Site.Params.LawFirmName}}",
        "logo": "{{ .Site.Params.logo2 | absURL }}",
        "founder": "{{ .Site.Params.founder }}",
        "foundingDate":  "{{ .Site.Params.foundingdate }}",
        "foundingLocation": "{{ .Site.Params.foundinglocation }}",
        "slogan": "{{ .Site.Params.slogan}}",
        "url": "{{ .Site.BaseURL}}",
        "image": {
            "@type": "imageObject",
            "url": "{{ .Site.BaseURL}}{{ .Params.image }}"
        },
        "aggregateRating": {
            "@type": "AggregateRating",
            "ratingValue": "{{.Site.Params.ratingValue }}",
            "reviewCount": "{{.Site.Params.reviewCount}}"
        },
        "telephone": "{{ .Site.Params.mobile }}",
        "currenciesAccepted": "{{.Site.Params.currency}}",
        "paymentAccepted": "{{ .Site.Params.paymentsAccepted | jsonify }}",
        "contactPoint": [{
            "@type" : "ContactPoint",
            "telephone": "{{ .Site.Params.mobile }}",
            "contactType": "customer service",
            "areaServed": "{{ .Site.Params.areaserved | jsonify }}", 
            "availableLanguage": "{{ .Site.Params.availableLanguage | jsonify }}",
            "hoursAvailable": "{{ .Site.Params.hoursAvailable }}"
        }],
        "sameAs": [
            "{{ .Site.Params.facebook }}",
            "{{ .Site.Params.linkedin }}",
            "{{ .Site.Params.SuperLawyers }}",
            "{{ .Site.Params.justia }}",
            "{{ .Site.Params.avvo }}"
        ],
        "description": "{{ .Site.Params.description }}",
        "address": {
            "@type": "PostalAddress",
            "streetAddress": "{{ .Site.Params.streetaddress }}",
            "addressLocality": "{{ .Site.Params.addresslocality }}",
            "addressRegion": "{{ .Site.Params.addressregion }}",
            "postalCode": "{{ .Site.Params.postalcode }}",
            "addressCountry": "{{.Site.Params.addresscountry}}"
        },
        "geo": {
            "@type": "GeoCoordinates",
            "latitude": "{{ .Site.Params.latitude }}",
            "longitude": "{{ .Site.Params.longitude }}"
        },
        "hasMap": "{{ .Site.Params.link }}",
        "openingHours": "{{ .Site.Params.hoursAvailable }}",
        "priceRange": "{{ .Site.Params.price }}",
        "areaServed": [{
            "@type": "Place",
            "name": "{{ .Site.Params.foundinglocation }}",
            "sameAs": "{{ .Site.Params.wikipediacity }}"
        },
        {"@type": "Place",
            "name": "{{ .Site.Params.areaserved }}",
            "sameAs": "{{ .Site.Params.wikipediacity }}"
        }
        ], 
        "memberOf": [
            {"@type": "Organization",
                "name": "{{ .Site.Params.org1name }}",
                "description": "{{ .Site.Params.org1description }}",
                "url": "{{ .Site.Params.org1url }}"
            },
            {"@type": "Organization",
                "name": "{{ .Site.Params.org2name }}",
                "description": "{{ .Site.Params.org2description }}",
                "url": "{{ .Site.Params.org2url }}"
            }
        ],
        "hasOfferCatalog": { 
          "@type": "OfferCatalog",
          "name": "Legal services",
          "itemListElement": [
              {{- $pages := where .Site.RegularPages "Params.practice_area" "Divorce" -}}
              {{- $jsonPages := slice -}}
              {{- range $pages -}}
              {{- $jsonPages = $jsonPages | append (dict "url" .Permalink "name" .Title) -}}
              {{- end -}}
              {{- range $index, $page := $jsonPages -}}
              {
                  "@type": "Offer",
                  "itemOffered": {
                      "@type": "Service",
                      "name": "{{ $page.name }}",
                      "url": "{{ $page.url }}"
                  }
              }{{- if ne $index (sub (len $jsonPages) 1) -}},{{- end -}}
              {{- end -}}
            ]
            } 
         }
     }
     </script>

Also passes core web vitals on mobile and should pass on desktop soon.

https://pagespeed.web.dev/analysis/https-www-sevenslegal-com/06fukqk9sx?form_factor=mobile

2 Likes

I am self taught and probably why i don’t know things like that. Also i know it can be improved on, like including video formatting and other things.

Please include your code in backticks.
```
code goes here
```
to make it easier to read.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.