[ad_1]
Schema.org辭彙表是最終的合作。
由於谷歌,微軟,雅虎和Yandex之間的相互握手,我們有一個領域庫,我們可以用來突出顯示網頁上的信息並更恰當地定義。通過利用結構化數據,我們為搜索引擎提供了更多的信心(即更好地理解頁面內容),正如Alexis Sanders所解釋的那樣 在這個精彩的播客。這樣做可以產生許多積極的影響,包括引人注目的SERP顯示和改進的排名。
如果您是SEO,您對使用Schema.org辭彙表審核或創建結構化數據標記有多大信心?如果您只是不舒服地換上了座位,那麼這就是您的指南。在其中,我的目標是揭開JSON-LD的一些語法的神秘面紗,並分享有關為網頁創建結構化數據的有用提示。
理解JSON-LD的語法
雖然您可以通過幾種不同的方式標記頁面內容,但本指南將重點介紹Google更喜歡的格式; JSON-LD。此外,我們不會涉及其所有複雜性,而是最常遇到並且對SEO有用的那些實例。
大括弧
開幕後你會注意到的第一件事 標籤,一個封閉的大括弧。
我們所有的結構化數據都將存在於這兩個大括弧中。當我們構建我們的標記時,我們可能會看到額外的花括弧,這就是縮進真正有助於防止事情變得太混亂的地方!
引號
接下來你要注意的是引號。每次我們調用Schema類型,屬性或填寫欄位時,我們都會將信息包裝在引號中。
冒號
接下來是冒號(沒有咯咯笑)。基本上,每次我們調用類型或屬性時,我們都需要使用冒號繼續輸入信息。這是一個欄位分隔符。
逗號
逗號用於設定另一個值(即更多信息)即將到來的期望。
請注意,填寫「logo」屬性的信息欄位後,沒有逗號。那是因為沒有其他信息需要說明。
括弧
當我們調用包含兩個或更多條目的屬性時,我們可以使用開括弧和閉括弧作為機箱。
了解我們如何在「sameAs」屬性中包含Go Fish Digital的Facebook和Twitter個人資料?由於有多個條目,我們將兩個條目括在括弧內(我將其稱為數組)。如果我們只包含Facebook網址,我們就不會使用括弧。我們只需將值(URL)包裝在引號中。
內花括弧
每當我們調用具有預期「類型」的屬性時,我們將使用內部花括弧來封閉信息。
在上圖中,調用了「contactPoint」屬性。這個特殊的屬性有一個預期的類型「ContactPoint」。這不是很好,令人困惑?稍後我們將詳細介紹它,但現在請注意,在調用「contactPoint」屬性後,會打開一個內部花括弧。在下一行,您將看到調用的ContactPoint類型。聲明了該類型中的屬性(「telephone」和「contactType」),然後關閉了內部花括弧。
在這個用例中還有其他一些東西,如果你現在能理解的話,將來會為你節省很多麻煩:
看看「客戶服務」之後沒有逗號。這是因為在該集合中沒有更多信息可供共享。但是在封閉的內部大括弧之後有一個逗號,因為有更多的數據要來(具體來說,「sameAs」屬性)。
使用在線生成器創建結構化數據標記
現在我們對語法有了一點了解,讓我們開始創建結構化數據標記。
如果您是初學者或作為創建基線標記以建立(並節省時間)的方法,在線生成器是很棒的。我最喜歡的是 Merkle的模式標記生成器,這是我將用於指南的這一部分的那個。
接下來,您需要選擇頁面和標記類型。在這個例子中,我選擇了 https://gofishdigital.com/ 作為我們的頁面和組織作為我們的標記類型。
填寫一些信息後,我們的工具為主頁創建了一些出色的基線標記:
希望在我們的語法課程之後,你可以毫無問題地閱讀這個例子中的大部分(或全部)!
使用文本編輯器創建自定義結構化數據標記
基線標記會很好,但我們可以超越在線生成器預設,完全控制,並為我們的頁面編寫漂亮的自定義結構化數據。上 https://schema.org/Organization,您將看到屬於組織標記類型的所有可用屬性。這比在線工具提供的要多得多,所以讓我們捲起袖子,遇到麻煩!
下載文本編輯器
此時,我們必須將訓練輪放好並留下在線工具(單個撕裂)。我們需要一個可以編輯和創建自定義標記的地方。我不會對此感到溫柔 – 得到一個 文本編輯器 現在。這物超所值,將為您提供遠遠超出結構化數據標記的服務。我將使用我最喜歡的文本編輯器Sublime Text 3。
專業提示:轉到視圖>語法> Javascript> JSON以適當地設置語法。
我已經將生成器中的一些基線組織標記粘貼到Sublime Text中。這是它的樣子:
添加屬性:簡易模式
頁面在 https://schema.org/Organization 具有組織類型的所有可用欄位。我們的基線標記沒有電子郵件信息,所以我查看了Schema頁面並發現了:
第一列顯示有一個電子郵件屬性。得分了!我將在結束括弧後添加一個逗號來設置更多信息的期望,然後我將添加「email」屬性:
Schema.org上的第二列是「預期類型」。這一次,它表示「文本」,這意味著我們只需輸入電子郵件地址即可。天哪,我很喜歡它。
讓我們繼續推動。我想確保我們的電話號碼是此標記的一部分,所以讓我們看看是否有一個屬性…
答對了。預期的類型只是「文本」。我將在「email」屬性之後添加一個逗號,並在「電話」中投入。在此示例中無需突出顯示任何內容;我可以告訴你,它已經掌握了它。
添加屬性:硬模式
接下來,我們將添加一個更複雜的屬性 – 「地址」屬性。就像「電子郵件」和「電話」一樣,讓我們跟蹤它 https://schema.org/Organization。
所以,我確實看到了「文本」,但我也看到了預期的「PostalAddress」類型。帶有數據標記的遊戲的名稱是:如果你可以更具體,那就更具體。讓我們點擊「PostalAddress」,看看那裡有什麼。
我看到許多需要簡單文本值的屬性。讓我們選擇其中一些屬性並添加我們的「地址」標記!
以下是我添加此標記的步驟:
- 在「電話」屬性後放置逗號
- 稱為「地址」屬性
- 由於「address」屬性具有預期的類型,我打開了內部花括弧
- 稱為「PostalAddress」類型
- 在「PostalAddress」類型中調用屬性
- 封閉內花括弧
你能從上面的圖片中發現所有這些嗎?如果是這樣,那麼恭喜你 – 你已經完成了硬模式!
創建一個複雜的數組
在我們關於括弧的討論中,我提到了一個數組。當屬性(例如「sameAs」)具有兩個或更多個條目時,可以使用數組。
這是一個簡單數組的一個很好的例子。但有時我們必須創建複雜的數組。例如,Go Fish Digital有兩個不同的位置。我們如何為此創建數組?
如果我們將其分解,這並不是那麼複雜。在北卡羅來納州的信息之後,你會看到一個封閉的內部花括弧。我剛輸入一個逗號,然後為Virginia位置添加了相同的類型(PostalAddress)和屬性。由於為「地址」屬性創建了兩個條目,因此我將整個內容括在括弧中。
使用@graph創建節點數組
2019年4月16日, Joost de Valk 從 Yoast 宣布Yoast SEO 11.0的到來,它擁有新的結構化數據標記功能。您可以在中查看更新的概述 這個帖子 從 這個視頻。但是,我想更深入地了解Yoast正在利用的一種特殊技術,為搜索引擎提供非常有用的信息,連接標記:使用@graph創建節點數組(*人群喘氣)。
代碼打開「@graph」,然後打開括弧,調用數組。這與上面標題為「創建複雜數組現在打開數組,你會看到一系列節點(或Schema類型):
- 組織
- 網站
- 網頁
- BreadcrumbList
- 文章
- 人
我已將每個分開(見下文),以便您可以輕鬆查看陣列的組織方式。每個節點內都有很多屬性,但真正的神奇之處在於「@id」。
在WebSite節點下,他們調用「@id」並聲明以下URL: https://yoast.com/#website。後來,在他們建立了WebPage節點之後,他們說網頁是其中的一部分 yoast.com 網站包含以下行:
「isPartOf」:{ 「@ ID」:」https://yoast.com/#website「}。
這有多棒?他們建立了有關網站和特定網頁的信息,然後在兩者之間建立了聯繫。
Yoast在Article節點下做同樣的事情。首先,在WebPage下,他們再次調用「@id」並將URL指定為 https://yoast.com/wordpress-seo/#webpage。然後,在文章下,他們告訴搜索引擎文章(或博客文章)是網頁的一部分,代碼如下:
「isPartOf」:{ 「@ ID」:」https://yoast.com/wordpress-seo/#webpage「}
在閱讀下面的標記時,請特別注意以下兩點:
- 上面列出的6個節點,每個節點分開以更好地可視化
- 「@id」和「isPartOf」調用,用於定義,建立和連接數組中的項目
Bravo,Yoast!
來源頁面: https://yoast.com/wordpress-seo/
{"@context":"https://schema.org",
"@graph":(
{
"@type":"Organization",
"@id":"https://yoast.com/#organization",
"name":"Yoast",
"url":"https://yoast.com/",
"sameAs":(
"https://www.facebook.com/yoast",
"https://www.instagram.com/yoast/",
"https://www.linkedin.com/company/1414157/",
"https://www.youtube.com/yoast",
"https://www.pinterest.com/yoast/",
"https://en.wikipedia.org/wiki/Yoast",
"logo":{"@type":"ImageObject",
"@id":"https://yoast.com/#logo",
"url":"https://yoast.com/app/uploads/2015/09/Yoast-Logo-Icon-120x120.png",
"caption":"Yoast"},
"image":{"@id":"https://yoast.com/#logo"}},
{
"@type":"WebSite",
"@id":"https://yoast.com/#website",
"url":"https://yoast.com/",
"name":"Yoast",
"publisher":{"@id":"https://yoast.com/#organization"},
"potentialAction":{"@type":"SearchAction",
"target":"https://yoast.com/?s={search_term_string}",
"query-input":"required name=search_term_string"}},
{
"@type":"WebPage",
"@id":"https://yoast.com/wordpress-seo/#webpage",
"url":"https://yoast.com/wordpress-seo/",
"inLanguage":"en-US",
"name":"WordPress SEO Tutorial u2022 The Definitive Guide u2022 Yoast",
"isPartOf":{"@id":"https://yoast.com/#website"},
"image":{"@type":"ImageObject",
"@id":"https://yoast.com/wordpress-seo/#primaryimage",
"url":"https://yoast.com/app/uploads/2008/04/WordPress_SEO_definitive_guide_FI.png",
"caption":""},
"primaryImageOfPage":{"@id":"https://yoast.com/wordpress-seo/#primaryimage"},
"datePublished":"2019-03-28T14:05:01+00:00",
"dateModified":"2019-04-11T12:24:14+00:00",
"description":"This is the ONLY tutorial you'll need to hugely increase your search engine traffic by improving your WordPress SEO. Want higher rankings? Read on!",
"breadcrumb":{"@id":"https://yoast.com/wordpress-seo/#breadcrumb"}},
{
"@type":"BreadcrumbList",
"@id":"https://yoast.com/wordpress-seo/#breadcrumb",
"itemListElement":(
{
"@type":"ListItem",
"position":1,
"item":
{"@type":"WebPage",
"@id":"https://yoast.com/",
"url":"https://yoast.com/",
"name":"Home"}},
{
"@type":"ListItem",
"position":2,
"item":{"@type":"WebPage",
"@id":"https://yoast.com/seo-blog/",
"url":"https://yoast.com/seo-blog/",
"name":"SEO blog"}},
{
"@type":"ListItem",
"position":3,
"item":{"@type":"WebPage",
"@id":"https://yoast.com/tag/wordpress/",
"url":"https://yoast.com/tag/wordpress/",
"name":"WordPress"}},
{
"@type":"ListItem",
"position":4,
"item":{"@type":"WebPage",
"@id":"https://yoast.com/wordpress-seo/",
"url":"https://yoast.com/wordpress-seo/",
"name":"WordPress SEO: the definitive guide"}})},
{
"@type":"Article",
"@id":"https://yoast.com/wordpress-seo/#article",
"isPartOf":{"@id":"https://yoast.com/wordpress-seo/#webpage"},
"author":{"@id":"https://yoast.com/about-us/team/joost-de-valk/#author",
"name":"Joost de Valk"},
"publisher":{"@id":"https://yoast.com/#organization"},
"headline":"WordPress SEO: the definitive guide",
"datePublished":"2019-03-28T14:05:01+00:00",
"dateModified":"2019-04-11T12:24:14+00:00",
"commentCount":"4",
"mainEntityOfPage":"https://yoast.com/wordpress-seo/#webpage",
"image":{"@id":"https://yoast.com/wordpress-seo/#primaryimage"},
"keywords":"Content SEO, Google Analytics, Mobile SEO, Security, Site Speed, Site Structure, Technical SEO, WordPress, Yoast SEO"},
{
"@type":"Person",
"@id":"https://yoast.com/about-us/team/joost-de-valk/#author",
"name":"Joost de Valk",
"image":{"@type":"ImageObject",
"@id":"https://yoast.com/#personlogo", "url":"https://yoast.com/app/uploads/2018/09/avatar_user_1_1537774226.png",
"caption":"Joost de Valk"},
"description":"Joost de Valk is the founder and Chief Product Officer of Yoast and the Lead Marketing & Communication for WordPress.org. He's a digital marketer, developer and an Open Source fanatic.",
"sameAs":(
"https://www.facebook.com/jdevalk",
"http://www.linkedin.com/in/jdevalk",
"https://twitter.com/jdevalk")}
)}
Troubleshooting your markup
With all these brackets, braces, and commas in play, mistakes can happen. So how do we detect and fix them?
Sublime Text error reporting
If you followed my pro tip above and set your syntax to JSON, Sublime Text will highlight certain errors for you.
Sublime Text has detected an error and made a highlight. It』s important to note that errors are 「reported」 in three ways:
- The error is the highlighted item.
- The error is somewhere on the highlighted line.
- The error is somewhere in a previous field.
In this case, it』s the third option. Did you spot it? There』s a missing comma after 「info@gofishdigital.com.」
Honestly, this error reporting can be confusing at first, but you』ll quickly get used to it and will start pinpointing the mistake(s) fairly easily.
Google』s structured data tool error reporting
Go to https://search.google.com/structured-data/testing-tool > New Test > Code Snippet. Paste and run your code. If there is an error, this is what you』ll see:
Click the error report and the tool will highlight the field after the error. As you』ll see, the missing comma after 「info@gofishdigital」 has caused the tool to highlight 「telephone.」 The logic there is that without the comma, that line actually is the error. It makes logical sense, but can be confusing, so it』s worth pointing out.
Sublime Text』s 「hidden」 underscore feature
Validating structured data markup can be maddening, and every little trick helps. As your structured data gets more complicated, the number of sections and brackets and curly braces is likely to increase. Sublime Text has a feature you may not have noticed that can help you keep track of everything!
In the above image, I』ve placed my cursor on the first line associated with the 「sameAs」 property. Look closely and you』ll notice that Sublime Text has underscored the brackets associated with this grouping. If the cursor is placed anywhere inside the grouping, you』ll need those underscores.
I often use this feature to match up my brackets and/or curly braces to be sure I haven』t left any out or added in an extra.
Validating your structured data
Of course, the ultimate goal of all this error checking is to get your code to validate. The troubleshooting tips above will help you develop a bulletproof method of error checking, and that you』ll end up with the euphoric feeling that validated markup gives!
Using Google search for unique cases
The lessons and examples in this guide should provide a solid, versatile knowledge base for most SEOs to work with. But you may run into a situation that you』re unsure how to accommodate. In those cases, Google it. I learned a lot about JSON-LD structured data and the Schema vocabulary by studying use cases (some that only loosely fit my situation) and fiddling with the code. You』ll run into a lot of clever and unique nesting techniques that will really get your wheels spinning.
Structured data and the future of search
The rumblings are that structured data is only going to become more important in moving forward. It』s one of the ways Google gathers information about the web and the world in general. It』s in your best interest as an SEO to untie the knot of JSON-LD structured data and the Schema vocabulary, and I hope this guide has helped do that.