Jekyll Pages API
Jekyll Pages API is a Jekyll Plugin gem that generates a JSON file with data for all the Pages in your Site. Jekyll, if you're not familiar, is a static website generator written in Ruby.
Usage
Add this line to your application's Gemfile:
group :jekyll_plugins do
gem 'jekyll_pages_api'
end
And then execute:
bundle
bundle exec jekyll serve
You can then see the generated JSON file at http://localhost:4000/api/v1/pages.json, which will look like this:
{
"entries": [
{
"title": "18F Hub",
// the page path
"url": "/",
// the content of the page, with the HTML tags stripped and the whitespace condensed
"body": "18F is a digital services team within GSA..."
},
// ...
]
}
This endpoint will be re-generated any time your site is rebuilt.
See also
Additional means of turning your site content into data:
- Jekyll's
jsonify
filter - jekyll-git_metadata
- jekyll-rss
- jekyll-sitemap
- Reading the YAML frontmatter of the source files
- Scraping the HTML pages themselves