Create a new plugin module test-cmspluginhello here, pop-up prompt Hello world when the page is loaded.

Create a new plugin module

Plugin is essentially an EggBorn module.

Go to the project directory and create a new module by executing the scaffold.

$ cd /path/to/project
$ npm init cabloy src/module/test-cmspluginhello --type=module

Modify package.json


  "name": "egg-born-module-test-cmspluginhello",
  "version": "1.0.0",
  "title": "cms:plugin:hello",
  "eggBornModule": {
    "cms": {
      "name": "hello",
      "plugin": true
  • name: Must follow the naming convention of the EggBorn module: egg-born-module-{providerId}-{moduleName}
    • providerId: Developer Id, strongly recommend Github’s Username to ensure that modules contributing to the community are not conflict
  • cms: CMS configuration information
    • name: Theme name
    • plugin: Declare this module is a plugin

Configure parameters

Plugins can provide custom parameters.


module.exports = appInfo => {
  const config = {};

  // plugin
  config.plugin = {
    _message: 'Hello World',

  return config;

Create initial script


$(document).ready(function() {
  // alert
  const message='<%=site.plugins['test-cmspluginhello']._message%>';

How to reference a script

Just declare the JS file in the rendering template.

Here, you can reference it in the homepage template of the test-cmsthemehello theme.


<% js('plugins/test-cmspluginhello/init.js.ejs') %>
  <script src=""></script>
  <script src="_ _JS_ _"></script>

Other source code and resources

Add other source code and resources as needed, abbreviated here.

Build module

As an EggBorn module, if it is used inside a project, it does not need to be built and can be used directly. If you want to share it to the community for other users to install and use, you must build.

$ cd src/module/test-cmspluginhello   -- Enter the module directory
$ npm run build:front             -- Build frontend code
$ npm run build:backend           -- Build backend code

Release module

You can publish the module to the community.

$ npm publish