Skip to content

Instantly share code, notes, and snippets.

@dleidert
Last active March 1, 2019 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dleidert/e5da76a36a2e9f9411b6f59b4e8a1d90 to your computer and use it in GitHub Desktop.
Save dleidert/e5da76a36a2e9f9411b6f59b4e8a1d90 to your computer and use it in GitHub Desktop.
Provide structured (website) data for a software application using JSON-LD and GitHub pages / Jekyll

Below is an example for a jekyll template to provide structed data in JSON-LD for a software application using the site.github namespace (provided by the github-metadata) plugin). Assuming there is at least one release, this snippet is a starting point. Content represented by three dots ... usually needs to be added manually to the snippet:

{%- assign release = site.github.latest_release -%}
{
  "@context": "http://schema.org/",
  "@type": "SoftwareApplication",
  "codeRepository": "{{ repository_url }}",
  "programmingLanguage": {
    "@type": "ComputerLanguage",
    "name": "{{ site.github.language }}",
  },
  "targetProduct": {
    "@type": "SoftwareApplication",
    "name": "{{ site.github.project_title | default: site.github.repository_name }}",
    "softwareVersion": "{{ release.tag_name | strip | remove: 'v' }}",
    "alternateName": [
      "...",
      "{{ release.name }}"
    ],
    "description": "{{ site.github.project_tagline }}",
    "applicationCategory": "...",
    "inLanguage": ["...", "..."],
    "operatingSystem": [
      "...",
      "...",
      "..."
    ],
    "downloadUrl": "{{ release.assets[0].browser_download_url | release.assets[0].html_url | default: site.github.releases_url }}",
    "fileSize": "{{ release.assets[0].size | divided_by: 1024 }}",
    "releaseNotes": [
      {{ release.body | jsonify }},
      "{{ release.html_url }}"
    ],
    "license": "{{ site.github.license.url | default: https://raw.githubusercontent.com/:user/:project/master/LICENSE }}",
    "url": "{{ site.github.repository_url }}",
    "datePublished": "{{ release.published_at }}",
    "dateCreated": "{{ release.created_at }}",
    "author": {%- include json/person.json -%},
    "publisher": {%- include json/person.json -%}
  },
  "creator": {%- include json/person.json -%}
}

The included file person.json could look like this (here based on the minima theme):

{%- assign social = site.minima.social_links -%}
{
  "@context": "http://schema.org/",  
  "@type": "Person",
  "name": "{{ site.author | default: site.github.owner.name }}",
  "email": "mailto:{{ site.email | default: site.github.owner.email }}",
  "url": "{{ site.github.owner.blog }}",
  "sameAs": [
    "https://github.com/{{ site.github_username | default: social.github | cgi_escape | escape }}",
    "https://instagram.com/{{ site.instagram_username | default: social.instagram | cgi_escape | escape }}",
    "https://www.xing.com/profile/{{ site.xing_username | default: social.xing | cgi_escape | escape }}",
    "https://m.youtube.com/channel/{{ site.youtube_username | default: social.youtube_channel | cgi_escape | escape }}",
    "https://pgp.mit.edu/pks/lookup?op=get&search={{ site.gnupg_key | default: social.gnupg | cgi_escape | escape }}",
    "{{ site.url }}"
  ]
}

The examples above don't test for the existence of variables and cannot be blindly copied. But they can be easily adapted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment