Join James Williamson for an in-depth discussion in this video Choosing a syntax, part of HTML: Structured Data.
- After exploring the many different options for adding structured data to your sites, you'll probably be left wondering which one you should use. Well, there really isn't a simple answer to that question, as there isn't a single best method. Rather, choosing a structured data syntax will depend on multiple factors that may differ from project to project. The first thing you'll want to consider is how you're planning on adding structured data to your pages. If you're gonna add it all by hand, you'll need to choose a syntax that's relatively easy to learn and write.
Developers might find writing JSON-LD easier, while designers may gravitate towards the class-based Microformats syntax. The key is experimenting with the syntaxes and then finding the one that best suits your Authoring style. You'll also want to make sure that any syntax you choose integrates well with your existing coding standards. Microformats are class-based and will validate well with older versions of HTML. Microdata and RDFa introduce new HTML attributes, while JSON-LD abstracts the data away from the content.
Making sure that any syntax you choose fits within your coding practices is critical to the success of adding structured data to your projects. Obviously, your overall goals are going to factor heavily in choosing the right syntax. You need to clearly define exactly why you want to add structured data to your pages. If you're primarily looking to improve your search result listings, Microdata, which is backed by Google, Yahoo, Bing, Yandex, and others might be the best choice. On the other hand, if you need to create and extend your own custom vocabularies, RDFa would be a better choice.
If you need to tie your structured data into your CSS styles, for example, the class-based Microformats makes a better solution. What it really boils down to is that there isn't any one "best" syntax. You're going to need to thoroughly research each of them to find the one that best suits your needs. In the end, you may even need to mix multiple syntaxes to achieve your goals. That's why instead of focusing on a single syntax in this course, we're going to experiment with Microdata, Microformats, RDFa, and JSON-LD.
I want to make sure that you understand the basics of each of these syntaxes as you begin working with structured data.
- Choosing a syntax
- Learning microformats
- Structuring contact data
- Adding contact names, titles, photos, and addresses
- Learning RDFa
- Structuring event data
- Providing event dates
- Adding an event URL
- Learning microdata
- Structuring products
- Setting product pricing
- Adding individual product reviews
- Learning JSON-LD
- Creating a knowledge graph