Junior
Junior

Reputation: 11990

How can I add custom attributes to a "Product" type in with JSON-LD?

I have a real estate website which displays real estate properties for sale. For each page where a property is listed, I want to create JSON-LD code to display information about the property, using Schema.org.

I am not sure if there is a better type to use than Product for real estate listings here.

How can I add a custom attribute to describe the property?

Here is a JSON-LD structure for Product:

{
  "@context": "https://schema.org/",
  "@type": "Product",
  "name": "address of the property ",
  "image": [
    "https://example.com/photos/1x1/photo.jpg",
    "https://example.com/photos/4x3/photo.jpg",
    "https://example.com/photos/16x9/photo.jpg"
   ],
  "description": "description about the houese"
  }
}

I want to be able to add other info like

Primary Features

  1. How many bedrooms it has
  2. How many bathrooms it has
  3. If it is a smart home or not
  4. etc...

Interior Features

  1. Fireplace
  2. Fireplace location
  3. etc...

Exterior Features

  1. The Lots Size
  2. Fets
  3. etc...

How can I add these custom attribute that describes the property using Schema.org?

Upvotes: 2

Views: 768

Answers (1)

unor
unor

Reputation: 96607

If you want to provide data about real estate, you need to use a type that represents real estate. Probably Accommodation (Apartment, House, …) for your case.

If you want to convey that this real estate is a product, you need to provide the Product type in addition to the Accommodation type.

Then you can use properties from Accommodation as well as Product.

{
  "@context": "https://schema.org/",
  "@type": ["House", "Product"],

  "offers": {
    "@type": "Offer"
  },

  "numberOfRooms": 4

}

Custom properties about the real estate can be added with the additionalProperty property, and, if applicable, with the amenityFeature property.

Upvotes: 4

Related Questions