Skip to content

Building Dynamic Apps with a Templating System

AZIRAR Mhamed (SNCF / DGA NUMERIQUE / e.SNCF Sol.D2D DDSP IDFCE) edited this page Apr 22, 2026 · 3 revisions

Creating Templates from Content (HTML, JSON, XML, etc.) in Nodify Headless CMS

Introduction

When building a dynamic page structure — for example, a landing page to promote your profile — it is often useful to use a templating system. This approach allows you to break your page into reusable components stored as independent content nodes, each identified by a unique code. These templates can be combined dynamically to generate a complete web page.

With Nodify Headless CMS (an open source solution built on Java), you can leverage a powerful API to manage and assemble templates across multiple formats: HTML, JSON, XML, and more. Built-in i18n support also allows you to serve localized templates effortlessly.

Defining Content Blocks

Each content block has a unique identifier and represents a part of the final page. Here is an example of how you might structure your templates:

Content Type Unique Code Format
Global template (main structure) html-1 HTML
Footer html-2 HTML
CSS for styling css-1 CSS
Body content (e.g., posts) html-3 HTML
JavaScript for API calls js-1 JS

These content nodes are stored independently and referenced dynamically in the final HTML structure.

Structuring the Homepage Template

When you assemble your homepage, you will dynamically inject content into the template using placeholders like $content(code). The homepage might look like this:

<html>
<head>
    <style>
        $content(css-1) <!-- CSS styles -->
    </style>
</head>
<body>
    $content(html-1) <!-- Header -->
    $content(html-3) <!-- Body -->
    $content(html-2) <!-- Footer -->
    <script>
        $content(js-1) <!-- JavaScript -->
    </script>
</body>
</html>

Nesting Templates

Templates can be nested within each other. For example, inside html-1 (the header), you can have sub-templates for elements like the site title or a category list:

<header>
    <h1>$content(site-title)</h1>
    <nav>
        $content(category-list)
    </nav>
</header>

This allows modularity while keeping the structure manageable.

API-Driven Templating

Because Nodify is a headless CMS, you can retrieve any template or content block via its REST API. For example:

GET /api/content/{code}

This makes it easy to integrate with any frontend framework (React, Vue, Angular, etc.) or static site generator. You can also output templates in JSON or XML format for headless scenarios.

Multilingual Templates (i18n)

With Nodify's i18n capabilities, you can maintain separate versions of each template for different languages:

/en/homepage-template
/fr/page-daccueil-template
/es/plantilla-portada

Then, dynamically serve the correct template based on the user's Accept-Language header or a URL prefix.

Benefits of Using Templates in Nodify

  1. Reusability – Components like footers, headers, and navigation bars can be reused across multiple pages.
  2. Maintainability – Updating a single template will reflect across all pages using it.
  3. Flexibility – You can dynamically change content without modifying the main template.
  4. Better Readability – Keeping the structure modular prevents code duplication and makes debugging easier.
  5. Open Source & Customizable – Being open source, you can extend the templating logic to suit your needs.
  6. Multi-format Support – Generate HTML, JSON, XML, or even plain text from the same content nodes.

Use Cases

Scenario Recommended Format Benefit
Web page rendering HTML Direct browser consumption
Mobile app content JSON Lightweight and easy to parse
RSS feed or sitemap XML Standardized structure for SEO
API response for third-party apps JSON / XML Interoperability
Multilingual website HTML + i18n Better international SEO

Conclusion

Using a templating approach to manage content dynamically makes building and maintaining complex pages easier. By separating CSS, HTML sections, and JavaScript into independent content nodes within Nodify Headless CMS — an open source, Java-based platform with a robust API and i18n support — you ensure flexibility, readability, and reusability in your project. Whether you need HTML for the web, JSON for APIs, or XML for feeds, Nodify's templating system has you covered.

#WebDevelopment #HTMLTemplates #DynamicContent #TemplatingSystem #ModularWebDesign #FrontendDevelopment #JavaScriptTemplates #ReusableComponents #WebsiteArchitecture #CMSIntegration #Nodify #HeadlessCMS #OpenSource #Java #API #i18n #JSON #XML #Multilingual #SEO

Clone this wiki locally