How to write valid opening hours with lunch break in schema.org with JSON-LD

Viewed 1120

I was reading all posts around this topic here but couldn't find a solution.

I'm building a page for a business that has the following opening hours:

Monday-Friday 07:00 - 12:00 and 13:00 - 17:00 (1 hour lunch break)

I can't find a way to write this as valid JSON-LD for my schema.org markup. Google's rich results test tool is not accepting my ideas and on schema.org documentation I cannot find any examples for a case like that.

The standard valid code without the lunch break looks like this:

"openingHoursSpecification": {
    "@type": "OpeningHoursSpecification",
    "dayOfWeek": [
      "Monday",
      "Tuesday",
      "Wednesday",
      "Thursday",
      "Friday"
    ],
    "opens": "07:00",
    "closes": "17:00"
  },

The code that I would like to have there is something like this, but I can't validate it and I can't find any examples that show how it's done.

"openingHoursSpecification": {
    "@type": "OpeningHoursSpecification",
    "dayOfWeek": [
      "Monday",
      "Tuesday",
      "Wednesday",
      "Thursday",
      "Friday"
    ],
    "opens": "07:00",
    "closes": "12:00",
    "opens": "13:00",
    "closes": "17:00"
  },
2 Answers

Schema has the property specialOpeningHoursSpecification that:

The special opening hours of a certain place. Use this to explicitly override general opening hours brought in scope by openingHoursSpecification or openingHours.

My suggestion for markup for your lunch:

<script type="application/ld+json">
  {
"@context":"https://schema.org",
  "@type":"Restaurant",
    "name":"GreatFood",
      "openingHoursSpecification":{
        "@type":"OpeningHoursSpecification",
          "dayOfWeek":[
            "Monday",
            "Tuesday",
            "Wednesday",
            "Thursday",
            "Friday"
          ],
            "opens":"07:00",
              "closes":"17:00"
      },
        "specialOpeningHoursSpecification":{
          "@type":"OpeningHoursSpecification",
            "dayOfWeek":[
              "Monday",
              "Tuesday",
              "Wednesday",
              "Thursday",
              "Friday"
            ],
              "closes": "12:00",
                "opens": "13:00"
        }
  }
</script>

I have not been able to find official examples for this property. I am confused by the following saying in the documentation about type OpeningHoursSpecification:

If the value for the closes property is less than the value for the opens property then the hour range is assumed to span over the next day.

The documentation of Schema does not explicitly indicate how this is accounted for the property openingHoursSpecification. Therefore, I do not know how it will be understood by search engines. Perhaps the best solution is to create an experiment and analyze the result.

The solution using hoursAvailable in these older posts seems to be working. Tested with Google's testing tool:

Original Post: Including "siesta" in Schema.org OpeningHoursSpecification in JSON-LD

Code from the original post:

{
    "@context": "http://schema.org",
    "@type": "Service",
    "url": "http://www.example.com/",
    "hoursAvailable": [{
        "@type": "OpeningHoursSpecification",
        "opens": "08:00",
        "closes": "13:00",
        "dayOfWeek": [{
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Monday",
            "name": "Monday"
        },
        {
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Tuesday",
            "name": "Tuesday"
        },
        {
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Wednesday",
            "name": "Wednesday"
        },
        {
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Thursday",
            "name": "Thursday"
        },
        {
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Friday",
            "name": "Friday"
        }]
    },
    {
        "@type": "OpeningHoursSpecification",
        "opens": "15:00",
        "closes": "20:00",
        "dayOfWeek": [{
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Monday",
            "name": "Monday"
        },
        {
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Tuesday",
            "name": "Tuesday"
        },
        {
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Wednesday",
            "name": "Wednesday"
        },
        {
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Thursday",
            "name": "Thursday"
        },
        {
            "@type": "DayOfWeek",
            "@id": "http://schema.org/Friday",
            "name": "Friday"
        }]
    }]
}
Related