{"id":15512305,"url":"https://github.com/jawebada/headless2static","last_synced_at":"2026-04-18T19:32:29.805Z","repository":{"id":56876122,"uuid":"289985686","full_name":"jawebada/headless2static","owner":"jawebada","description":"the missing link between headless content management systems and static site generators","archived":false,"fork":false,"pushed_at":"2021-07-06T19:02:32.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T13:47:34.462Z","etag":null,"topics":["directus","headless-cms","jekyll","liquid","ruby","static-site-generator"],"latest_commit_sha":null,"homepage":"https://jawebada.github.io/headless2static/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jawebada.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-24T16:50:24.000Z","updated_at":"2022-02-14T17:44:42.000Z","dependencies_parsed_at":"2022-08-20T11:31:06.674Z","dependency_job_id":null,"html_url":"https://github.com/jawebada/headless2static","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jawebada/headless2static","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawebada%2Fheadless2static","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawebada%2Fheadless2static/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawebada%2Fheadless2static/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawebada%2Fheadless2static/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jawebada","download_url":"https://codeload.github.com/jawebada/headless2static/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawebada%2Fheadless2static/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31982619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["directus","headless-cms","jekyll","liquid","ruby","static-site-generator"],"created_at":"2024-10-02T09:53:35.125Z","updated_at":"2026-04-18T19:32:29.772Z","avatar_url":"https://github.com/jawebada.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"{% raw %}\n\n# headless2static\n\n## Synopsis\n\n`headless2static` is a simple command line pogram which renders collections of\nREST resources to static files using a\n[Liquid](https://shopify.github.io/liquid/) template.\n\n## Introduction\n\nAre you considering using a [headless content management system\n(CMS)](https://en.wikipedia.org/wiki/Headless_content_management_system)?\n\nGreat, I am convinced that separating content editing from design is usually\nthe right thing to do.\n\nNow, it turns out you will need a frontend. And maybe we are talking about a\npretty simple website and you would prefer to use a [static site generator\n(SSG)](https://www.staticgen.com/)?\n\nSo how do you get your SSG to render the data served by your headless CMS?\nWell, it depends on your SSG. If you are lucky, it includes a data plugin for\nyour headless CMS of choice. However, *virtually all SSGs* support rendering\ninput from your file system (Markdown in particular).\n\nAnd that is where *headless2static* comes into play. It is the very simple\ncommon denominator of headless content management systems and static site\ngenerators. Just call it to render input files for your SSG from the REST\nresource lists of your headless CMS' API.\n\n## Example\n\nImagine there is an endpoint of your headless CMS' API (which might be\n[Directus](https://directus.io/)) at `https://example.com/api/items/pages`\nwhich returns something like this:\n\n```javascript\n{\n  \"data\": [\n    {\n      \"id\": 1,\n      \"status\": \"published\",\n      \"sort\": 1,\n      \"owner\": 1,\n      \"created_on\": \"2020-08-21T15:01:01+00:00\",\n      \"title\": \"A Test\",\n      \"content\": \"\u003cp\u003eLooks good.\u003c/p\u003e\\n\u003ch2\u003eA Header\u003c/h2\u003e\\n\u003cul\u003e\\n\u003cli\u003eList Item 1\u003c/li\u003e\\n\u003cli\u003eList Item 2\u003c/li\u003e\\n\u003c/ul\u003e\\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\",\n      \"navigation_title\": \"Test\"\n    },\n    {\n      \"id\": 2,\n      \"status\": \"published\",\n      \"sort\": 2,\n      \"owner\": 1,\n      \"created_on\": \"2020-08-21T15:05:59+00:00\",\n      \"title\": \"Another Page\",\n      \"content\": \"\u003cp\u003eIt works!\u003c/p\u003e\",\n      \"navigation_title\": null\n    }\n  ]\n}\n```\n\nCreate a [Liquid](https://shopify.github.io/liquid/) template called `{{title |\nslugify}}.html` (yes, that *is* the file name):\n\n```liquid\n---\nlayout: page\ntitle: {{title}}\nnavigation_title: {{navigation_title}}\n---\n{{content}}\n```\n\nCalling\n\n```shell\nheadless2static '{{title | slugify}}.html' https://example.com/api/items/pages\n```\n\nwill render two files:\n\n`a-test.html`:\n\n```html\n---\nlayout: page\ntitle: A Test\nnavigation_title: Test\n---\n\u003cp\u003eLooks good.\u003c/p\u003e\n\u003ch2\u003eA Header\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003eList Item 1\u003c/li\u003e\n\u003cli\u003eList Item 2\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n```\n\nand `another-page.html`:\n\n```html\n---\nlayout: page\ntitle: Another Page\nnavigation_title: \n---\n\u003cp\u003eIt works!\u003c/p\u003e\n```\n\n## Invocation\n\n```\nusage: headless2static [options] template_file url\n    -o, --output-directory=DIR       directory in which the output files are saved\n    -f, --force                      overwrite existing files\n```\n\n`headless2static` parses the template file, makes a GET request to the URL and\nrenders the template once for each item returned in the JSON response. The\nfollowing response variants are supported:\n\n* `[ { }... ]`: loop over array values,\n* `{ 'data': [ { }... ] }`: loop over data array values\n* `{ }`: render object\n\nThe output files are written to `DIR`, which defaults to `.`. Existing files\nare not overwritten unless the `-f` option is used.\n\n## Templates\n\nThe template file uses the [Liquid](https://shopify.github.io/liquid/) template\nlanguage. [Jekyll filters](https://jekyllrb.com/docs/liquid/filters/), in\nparticular `slugify`, are also supported.\n\nThe name of the template file determines the name of the output file. In order\nto create unique file names for collection items the template file name may\nalso include Liquid code, e.g., `{{title | slugify}}.html`.\n\n## Installation\n\n`headless2static` is written in Ruby and available as [a\ngem](https://rubygems.org/gems/headless2static).\n\nYou can install it calling\n\n```\ngem install headless2static\n```\n\n## Licence\n\nMIT\n\n{% endraw %}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjawebada%2Fheadless2static","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjawebada%2Fheadless2static","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjawebada%2Fheadless2static/lists"}