to navigate
to select
esc to close
GET Templates

Templates API

https://api.airogelcms.com/v1/accounts/:account_id/templates

Liquid templates for rendering content. Templates define the HTML structure and presentation logic for your site.

Supported Operations

  • GET /v1/accounts/:account_id/templates - List templates
  • GET /v1/accounts/:account_id/templates/:id - Get a template
  • POST /v1/accounts/:account_id/templates - Create a template
  • PUT /v1/accounts/:account_id/templates/:id - Update a template
  • DELETE /v1/accounts/:account_id/templates/:id - Delete a template

Template Types

  • Layouts: Define the overall page structure (header, footer, navigation)
  • Templates: Define content-specific rendering (blog post, product page)
  • Partials: Reusable components included in other templates

Liquid Context

Templates have access to:

  • Entry fields (for collection entries)
  • Global variables
  • Navigation menus
  • Custom Liquid tags and filters

Parameters

Name Type Required Description
account_id string Required Your account ID
handle string Optional Filter by exact handle match
page integer Optional Page number (default: 1)

Request Example

# Create template
curl -X POST \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "template": {
      "title": "Blog Post",
      "handle": "post",
      "html": "
\n

{{ title }}

\n
\n {{ body }}\n
\n
" } }' \ https://api.airogelcms.com/v1/accounts/$ACCOUNT_ID/templates # Update template curl -X PUT \ -H "Authorization: Bearer $API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "template": { "html": "
\n

{{ title }}

\n

{{ published_at | date: \"%B %d, %Y\" }}

\n {{ body }}\n
" } }' \ https://api.airogelcms.com/v1/accounts/$ACCOUNT_ID/templates/post

Response Example

{
  "id": "tmplt_abc123",
  "handle": "post",
  "title": "Blog Post",
  "html": "
\n

{{ title }}

\n {{ body }}\n
", "created_at": "2025-01-08T12:00:00Z", "updated_at": "2025-01-08T12:00:00Z" }

Additional Notes

Syntax validation: The API validates Liquid syntax before saving. Invalid templates will return a 422 validation error.

Template assignment: Templates are assigned to collections (for index pages) or individual entries. Collections and entries can also override the default layout.

Common Liquid tags in Airogel CMS:

  • {% cms_scripts %} - Include required CMS JavaScript
  • {% form_for %} - Render forms with proper structure
  • {{ content_for_header }} - SEO meta tags and scripts

See the Liquid Templates Guide for complete documentation.