Skip to content

An Eleventy blog boilerplate powered by a WordPress backend.

License

Notifications You must be signed in to change notification settings

saschazar21/eleventy-wordpress

Repository files navigation

Eleventy 🤝 WordPress

An Eleventy blog boilerplate powered by a WordPress backend.

GitHub Actions: Deploy to Netlify workflow GitHub Actions: Test workflow License


What is it?

This repository contains an Eleventy boilerplate, as well as an AWS Lambda-compatible Netlify Function acting as a webhook target, for fetching data from a WordPress REST API and automatically commit and push to the Github repository stored in the package.json file.

After updating the repository, preconfigured Github Actions rebuild and re-deploy the newly built site contents back to Netlify.

This way, access to the WordPress REST API and/or SQL database is not crucially needed for intermediate builds, as their latest content versions are always contained within this repository and even survive data loss within WordPress.

Getting started

Prerequisites

Quick start

  1. Install dependencies

    yarn # or npm install
  2. Populate Eleventy's data sources locally. (Wordpress instance needs to be reachable)

    REST_API=<WordPress REST API endpoint> ts-node scripts/fetch.ts
  3. Run development preview

    yarn dev # or npm run dev

External deployment

Prerequisites

  • Account at Netlify
  • Enabled Github Actions setup, incl. necessary environment variables (see .env.sample and deploy-to-netlify.yml - Deploy to Netlify step), OR
  • directly build at Netlify (untested, set environment variables in .env.sample there, disable Github Actions)
  • WordPress deployed somewhere with accessible REST API

Webhook

To trigger a new deployment, the /wp/hook endpoint needs to be called using a POST request (the request body is ignored by default).

Any WordPress plugin, which is capable of sending a POST request (preferably with Basic authentication) whenever contents have changed should do. Something like this one: WP Webhooks.

Or, if periodical updates are preferred over updates based on content changes, something like Netlify's Scheduled Functions might do the trick.

License

Licensed under the MIT license.

Copyright ©️ 2022 Sascha Zarhuber

About

An Eleventy blog boilerplate powered by a WordPress backend.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published