# Content

Build websites and site content with the Content plugin: page templates, design, and CMS-powered Next.js apps.


The Content plugin is the erxes CMS and website layer. It stores posts, pages, menus, categories, tags, and custom fields per site, serves them over GraphQL, and can build and deploy a rendered website through the Web Builder.

## Projects

The plugin has two projects in the `erxes/erxes` monorepo:

| Project | Path | Runs on |
| --- | --- | --- |
| `content_api` | `backend/plugins/content_api` | Plugin GraphQL service, port **3303** |
| `content_ui` | `frontend/plugins/content_ui` | Module Federation remote, dev server port **3003** |

`content_api` has two modules. [`src/modules/cms`](https://github.com/erxes/erxes/tree/f91e8c6f4714c910a32c6b6e14fe085f6435c89e/backend/plugins/content_api/src/modules/cms) handles websites-as-CMS-sites, posts, pages, menus, categories, tags, custom post types, custom fields, and translations. [`src/modules/webbuilder`](https://github.com/erxes/erxes/tree/f91e8c6f4714c910a32c6b6e14fe085f6435c89e/backend/plugins/content_api/src/modules/webbuilder) handles Web Builder site and page records plus the Vercel deployment pipeline in `utils/utils.ts`.

`content_ui` mounts its routes under `/content` and registers two entries in [`src/config.tsx`](https://github.com/erxes/erxes/blob/f91e8c6f4714c910a32c6b6e14fe085f6435c89e/frontend/plugins/content_ui/src/config.tsx): `cms` at `/content/cms` and `web-builder` at `/content/web-builder`. Feature internals live in `src/modules/cms` and `src/modules/web-builder`.

## Key concepts

- **A Client Portal is a website's identity.** CMS and Web Builder records carry a `clientPortalId` that ties them to one site. The portal itself is a core-api `clientportal` record, and the standalone [Client Portal](https://erxes.io/docs/app-client-portal) Next.js template (`apps/client-portal-template`) uses `cp*` operations with a portal token.
- **Two operation families.** `cp*` operations such as `cpPostList`, `cpCmsPageDetail`, and `cpMenus` serve website integrations; the gateway identifies the portal from the `x-app-token` JWT and the resolvers are flagged `forClientPortal`. `cms*` operations such as `cmsPageList` and `cmsMenus` serve the admin UI, go through the permission wrapper, and require an explicit `clientPortalId`. `cp*` is not read-only; it also includes writes like `cpCmsPagesAdd`.
- **Pages carry sections.** `Page.pageItems` is an ordered list of items with `name`, `type`, `content`, `order`, `objectType`/`objectId`, and a free-form JSON `config`. A front-end template maps those items to components.
- **Menus have a `kind`.** The Web Builder deployer collects `kind: "main"` and `kind: "footer"` menu items to build site navigation.
- **Templates live outside this repo.** `cpDeployWeb` clones `github.com/erxes-web-templates/<templateId>`, writes `data/configs.json` and `data/pages/<slug>.json` into it, and deploys to Vercel. The product repo defines the data shape; the template repositories define the rendering.

## Enable the plugin

The plugin name is `content`. Enable it in `.env`, then start the dev services:

```dotenv
ENABLED_PLUGINS=content
```

```bash
pnpm dev:apis   # includes content_api on :3303
pnpm dev:uis    # serves core-ui with the content_ui remote on :3003
```

To run one project, use `pnpm nx serve content_api` or `pnpm nx serve content_ui`. The API gateway on port 4000 composes the plugin's GraphQL subgraph.

## Guides

Pick the track that matches your role. The last card is the standalone Client Portal Next.js app, not part of the CMS or Web Builder tracks.

- [For Template developers](https://erxes.io/docs/content-template-developers): Build and customize storefront templates on the Web Builder boilerplate with UI-only changes.
- [For UI Designers](https://erxes.io/docs/content-ui-designers): Design web templates in Figma and map them to Web Builder sections, layouts, and pages.
- [For CMS + Next.js developers](https://erxes.io/docs/content-cms-developers): Integrate the erxes CMS with Next.js: setup, data queries, rendering, and migration.
- [Client Portal](https://erxes.io/docs/app-client-portal): Standalone portal backed by portal tokens

