Merged
Conversation
- _includes/organization-json-ld.json テンプレートを新規作成 - head.html に JSON-LD 埋め込みロジックを追加 - Schema.org 標準に完全準拠(非標準プロパティは含めない) - SEO 強化と Google ナレッジパネル表示の向上を目的とする 参考: mitou/jr.mitou.org#238
- _includes/website-json-ld.json テンプレートを新規作成 - head.html の条件分岐を簡素化(企業ページ以外は WebSite タイプ) - page.lang パラメータで description を多言語対応 - json_ld_check.rb を拡張して WebSite タイプも検証 テスト結果: 全 1023 ファイルで JSON-LD が正しく生成されていることを確認
- JSON の妥当性のみを検証(構文チェック) - Schema.org の詳細検証は外部ツールに委譲 - コード量を 76 行から 23 行に削減(約 70% 削減) 詳細な Schema.org 検証は以下のツールで実施可能: - Google Rich Results Test - Schema.org Validator
- 英語: "Tech companies in Japan that hire remote workers." - 日本語: "リモートワークを採用している日本のテクノロジー企業のまとめ。" WebSite タイプの JSON-LD で page.lang に応じて適切な description を表示
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Schema.org の構造化データ(JSON-LD)を全ページに実装しました:
変更内容
1. Organization タイプ(企業ページ)
_includes/organization-json-ld.jsonテンプレートを新規作成2. WebSite タイプ(その他のページ)
_includes/website-json-ld.jsonテンプレートを新規作成page.langパラメータで description を多言語対応3. 多言語対応
_data/translations.ymlに日本語版titleDescriptionを追加4. 自動テスト
_tests/json_ld_check.rbによる JSON-LD 検証を実装生成される JSON-LD の例
Organization タイプ(企業ページ)
{ "@context": "https://schema.org", "@type": "Organization", "name": "YassLab 株式会社", "url": "https://yasslab.jp/ja/", "description": "『Ruby on Railsチュートリアル』『Ruby on Railsガイド』『coderdojo.jp』の開発・運営。 » GitHub を見る", "address": { "@type": "PostalAddress", "addressCountry": "JP" } }WebSite タイプ(日本語トップページ)
{ "@context": "https://schema.org", "@type": "WebSite", "name": "Remotework.jp", "url": "https://remotework.jp/", "description": "リモートワークを採用している日本のテクノロジー企業のまとめ。", "inLanguage": ["en", "ja"] }WebSite タイプ(英語トップページ)
{ "@context": "https://schema.org", "@type": "WebSite", "name": "Remotework.jp", "url": "https://remotework.jp/", "description": "Tech companies in Japan that hire remote workers.", "inLanguage": ["en", "ja"] }実装の工夫
シンプルな条件分岐:
{% if page.layout == 'post' and page.domain %} <!-- Organization タイプ --> {% else %} <!-- WebSite タイプ(デフォルト) --> {% endif %}多言語対応:
_data/translations.ymlのtitleDescription[page.lang]を活用シンプルなテスト: JSON 構文の妥当性のみをチェック(23行)
包括的なカバレッジ: 全 1023 ファイルで JSON-LD が正しく生成されていることを確認
テスト結果
期待される効果
参考
検証方法
以下のツールで JSON-LD の妥当性を確認できます: