ApostropheCMS Documentation

repository·main·Indexed 26 days ago

https://github.com/apostrophecms/apostrophe

A full-stack content management system built with Node.js and MongoDB, featuring in-context editing and headless flexibility. This documentation covers the core system and specialized modules including @apostrophecms/ai-helper for AI-powered content generation (supporting OpenAI, Anthropic, and Gemini), @apostrophecms/anchors for automatic widget anchor generation, and @apostrophecms/apostrophe-astro for integrating ApostropheCMS with Astro 3.x and 4.x in SSR mode.

Tokens
107.3K
Snippets
316
Records
615
Agent score
89%

What's inside ApostropheCMS

  1. Overview of uploadfs

    main

    uploadfs is a module that copies files to a web-accessible location and provides consistent URLs for those files. It supports various backends including S3, Azure, GCS, and local filesystems.

    Key capabilities include:

    • Automatic directory creation.
    • Automatic content-type inference from extensions.
    • Image processing: resizing, cropping, and automatic rotation (e.g., for iPhone photos).
    • Support for non-image files and animated GIFs.
    • Ability to enable/disable web access to files.
    • Support for post-processors like imagemin to minimize file sizes.
  2. Enterprise API capabilities with ApostropheCMS Pro

    main

    The OpenAPI generator can be used with ApostropheCMS Pro extensions to document enterprise-grade endpoints. Upgrading to Pro unlocks dedicated API endpoints for features such as:

    • SEO Assistant: AI-powered content optimization.
    • Document Versions: Revision management and rollback APIs.
    • Advanced Permissions: Granular access control and user group management.
    • Automatic Translation: Multilingual content generation with AI-powered translations.

    To access these endpoints, you must create an account on Apostrophe Workspaces and upgrade your license.

  3. Generate structured data with Schema.org markup

    main

    The SEO module automatically generates JSON-LD structured data to help search engines understand your content. It outputs all data in a single <script type="application/ld+json"> tag using a @graph array for performance.

    Markup is generated based on the schema type selected in the SEO tab of the editor. The module handles:

    • Sitewide schemas: WebSite and Organization data from Global settings.
    • Page-level schemas: WebPage, CollectionPage, or specific entity types.
    • Primary entities: Article, Product, Event, Person, etc., for detail pages.
    • Item listings: Automatic ItemList generation for index/listing pages.
  4. SEO Module Feature Levels

    main

    The SEO module provides functionality at two distinct levels:

    Out-of-the-box (No Setup Required)

    • Essential meta tags: Title, description, and robots.
    • Analytics: Google Analytics, Tag Manager, and Site Verification.
    • Site control: Automated robots.txt and llms.txt generation.
    • Basic structured data: WebPage and CollectionPage schemas.

    Advanced Structured Data (Requires Content Structure Setup)

    Advanced schemas require specific field names in your content types to function correctly. If field names do not match, JSON-LD validation may fail in Google's tools. Examples include:

    • Article/Review: Requires author information.
    • Product/HowTo: Benefits from featured images.
    • Recipe: Requires a featured image.
    • VideoObject: Requires a thumbnail and upload date.
    • JobPosting: Requires multiple complex fields for Google for Jobs.
    • Event/LocalBusiness: Requires address/location fields.
    • FAQPage/QAPage: Requires question and answer content.
  5. ApostropheCMS Pro Form Features

    main

    ApostropheCMS Pro provides advanced enterprise-grade features for form management that extend the open-source version:

    • Advanced Permissions: Control which teams can create, edit, or manage specific form types (e.g., restricting HR or customer data forms).
    • Automated Translation: AI-powered translation (DeepL, Google Translate, Azure) for forms and confirmation messages.
    • Document Management: Version control and audit trails for form fields and modification history.
    • Visual Design Tools: In-context CSS customization via the Palette extension for styling forms without code.
  6. Configure XLSX format for Import Export

    main

    After installation, you must register the module in your app.js file. Ensure that both @apostrophecms/import-export and @apostrophecms/import-export-xlsx are included in your modules configuration object.

    require('apostrophe')({
      shortName: 'my-project',
      modules: {
        '@apostrophecms/import-export': {},
        '@apostrophecms/import-export-xlsx': {}
      }
    });
  7. Replace an npm module with a custom implementation

    main

    To completely replace an existing npm module (e.g., monsters) with a superior one (e.g., scary-monsters) without changing existing code, use the replace property in your new module's index.js.

    In your new module (scary-monsters/index.js):

    module.exports = {
      replace: 'monsters',
      construct: function(self, options) { ... }
    };

    When an application developer configures scary-monsters, moog-require will treat it as the monsters type. Any code calling synth.create('monsters', {}) will actually instantiate the replacement.

    // In scary-monsters/index.js
    module.exports = {
      replace: 'monsters',
      construct: function(self, options) { ... }
    }
    
    // In app.js
    var synth = require('moog-require')({
      localModules: __dirname + '/lib/modules',
      defaultBaseClass: 'module'
    });
    
    synth.define({
      'scary-monsters': { ... configuration ... }
    });
    
    // This works and returns the replacement
    synth.create('monsters', {});
  8. Configure the Base URL for SEO

    main

    Setting the baseUrl is required for proper canonical link generation and SEO performance. If you are using ApostropheCMS hosting, this is set automatically. Otherwise, you must configure it via an environment variable or in your configuration file.

    export APOS_BASE_URL=https://yoursite.com
    // data/local.js
    export default {
      baseUrl: 'https://yoursite.com',
      modules: {
        // other module configuration
      }
    };
  9. Package multiple modules in a single npm module (Bundles)

    main

    To bundle multiple moog-require modules within a single npm package, the npm package's entry point (index.js) must export a moogBundle object. This object specifies the names of the modules and the directory where they reside.

    Bundle Structure:

    • node_modules/mybundle/index.js: Exports moogBundle.
    • node_modules/mybundle/lib/modules/[module-name]/index.js: The actual module definitions.

    Example moogBundle configuration:

    // node_modules/mybundle/index.js
    module.exports = {
      moogBundle: {
        modules: [ 'module-one', 'module-two' ],
        directory: 'lib/modules'
      }
    };

    Usage in application:

    var synth = require('moog-require')({
      bundles: [ 'mybundle' ],
      localModules: __dirname + '/lib/modules',
      defaultBaseClass: 'module'
    });
    
    synth.define({
      'module-one': {},
      'module-two': {}
    });
    // In node_modules/mybundle/index.js
    module.exports = {
      moogBundle: {
        modules: [ 'module-one', 'module-two' ],
        directory: 'lib/modules'
      }
    };
    
    // In our application
    var synth = require('moog-require')({
      bundles: [ 'mybundle' ],
      localModules: __dirname + '/lib/modules',
      defaultBaseClass: 'module'
    });
    
    synth.define({
      'module-one': {},
      'module-two': {}
    });