Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 14, 2020 03:11 pm GMT

JSON-LD: What It Is and How DEV Uses It

Over the last six weeks, DEV has focused on improving its search engine optimization, and conforming the site to best practices. As the team member running point on this project, I've immersed myself in all things SEO.

This article is an attempt to distill and un-silo my knowledgewe will briefly discuss JSON-LD versus traditional implementations that leverage meta tags and then explore how DEV has migrated to using JSON-LD for our site.

JSON- What?

JSON-LD stands for JavaScript Object Notion for Linked Data. JSON-LD makes it simple to structure the data on a site for web crawlers by disambiguating elements, thus making the webpage using it more indexable, in turn bolstering the sites SEO. The JSON-LD for a page is generally found within a <script> tag in a pages <head> tag, though finding the data within a <body> tag is not uncommon. Placing structured data within the <head> tag is considered best practice, though, since crawlers generally begin searching for metadata in <head> tags.

What makes JSON-LD so usable is its syntax, which makes it easily readable by humans and machines. The linked data format consists of key-value pairs, containing Schema.org vocabulary, a shared vocabulary for structuring data, so machines can quickly interpret the content of the page. Leveraging the Schema.org vocabulary makes it possible to describe a litany of item types and item properties, with varying detailtypes can inherit from parent properties and other types.

There a few basic attributes that make up the general JSON-LD structure, aside from essential<script> tags: @context, @type, and the attribute-value pairs for the given object. All of the essential elements that make up a basic JSON-LD structure, aside from the <script> tags, can be found wrapped in double quotation marks () and ending with a comma. The <script> tags containing the structured data will always specify its type as JSON-LD: <script type=application/ld+json>. Similar to the <script> tags, the @context attribute should always specify Schema.org: @context: Schema.org,. Unlike the other essential attributes that make up the data structure, @type and the structures attribute-value pairs change depending on the items type and properties.

For our visual learners, I have included an example below of what the structured data for a DEV Organization looks like:

<script type=application/ld+json>{"@context": "http://schema.org","@type": "Organization","mainEntityOfPage": {   "@type": "WebPage",    "@id": URL.organization(@organization)    },  "url": URL.organization(@organization),  "image": ProfileImage.new(@organization).get(width: 320),  "name": @organization.name,  "description": @organization.summary.presence || "404 bio not found"}</script>

Looking at the above structure, youll see the necessary attributes that make up the skeleton of a JSON-LD structure: "<script type=application/ld+json>","@context", "@type". There are some additional attribute-value pairs pointing to necessary information that we at DEV have aimed to disambiguate for search crawlers, like Google's, as well.

DEV- How?

Now that weve covered the basics of JSON-LD and the vocabulary that it uses, its time to talk briefly about how DEV uses JSON-LD to structure its data and boost its SEO.

Prior to switching to JSON-LD in the last six weeks, the DEV codebase previously relied on <meta> tags in addition to specifying itemTypes and itemProps. While this approach works, it wasnt working as well as JSON-LD could and we werent feeling satisfied with its results. With our SEO plateauing, it was time to make our data more structured. The solution? Move away from using <meta> tags, itemTypes, and itemProps and migrate towards structuring our data using JSON-LD.

The switch to JSON-LD was nice because it is well documented, there are many examples to draw inspiration from, and there are useful testing tools, like Googles own Google Structured Data Testing Tool. The same is true for Schema.orgthe vocabularys documentation is easy to parse and item type and property examples are plentiful.

This being said, implementing JSON-LD was a learning experience for the entire team (as is any new coding endeavor!). Through our joint effort, we were able to structure the data for many of our major pages and our most important data in only a couple of weeks. Currently, the data for Article show pages, User profile pages, Organization profile pages, and Video show pages are structured using JSON-LD and the Schema.org vocabulary.

This snippet shows what the structured data for a Users profile page looks like. Note: For brevity, Ive included most, but not all, of the code for that makes up the structured data within the Stories::Controller.

In the Stories::Controller:

def set_user_json_ld @user_json_ld = {"@context": "http://schema.org","@type": "Person","mainEntityOfPage": {  "@type": "WebPage",  "@id": URL.user(@user)  },"url": URL.user(@user),"sameAs": [],"image": ProfileImage.new(@user).get(width: 320),"name": @user.name,"email": ,"jobTitle": ,"description": @user.summary.presence || "404 bio not found","disambiguatingDescription": [],"worksFor": [  {    "@type": "Organization"  },],"alumniOf": }end

And in the users/show Template:

<% unless internal_navigation? || user_signed_in? %>  <script type="application/ld+json">    <%= @user_json_ld.to_json.html_safe %>  </script><% end %>

I should also note that in order to make our structured data reusable and to keep our views clean, we opted to extract all of the logic for our structured data out into the set_user_json_ld method within the Stories::Controllerwe found that this implementation works best for us.

Since switching to JSON-LD, DEV has seen a dramatic increase in its SEO. Through disambiguating elements and organization, we were able to boost our SEO by making it easier for Google and its crawlers to navigate our site and its pertinent information.

How do you plan on implementing JSON-LD to improve your SEO?


Original Link: https://dev.to/juliannatetreault/json-ld-what-it-is-and-how-dev-uses-it-4d25

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To