Description

This function publishes a Site Publisher website.
  • This function uses the /scripts/process_site_template script to publish the Site Publisher website.
  • This function creates the configurations.json file in the specified directory.
    • This file contains the user-entered data for the Site Publisher website and uses 0700 permissions.
    • For more information, read our Guide to Site Publisher Templates documentation.
  • In cPanel & WHM version 58 and later, when users publish a Site Publisher website, the system first creates a backup tarball of the target directory's contents in the /site_publisher/backups/ directory within the user's home directory.
  • When users publish a Site Publisher website, the system logs template information and the target directory to the /usr/local/cpanel/logs/error_log file. 
  • The template directory's location depends on whether the root user or a reseller owns the template:

Examples 




https://hostname.example.com:2083/cpsess##########/execute/SiteTemplates/publish?target=%2Fhome%2Fexample%2Fpublic_html&source=%2Fusr%2Flocal%2Fcpanel%2F3rdparty%2Fshare%2Fsite_templates%2Funder_construction&sitename=My%20Website&description=I%20have%20a%20website%20now



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Publish a Site Publisher website.
$templates = $cpanel->uapi(
    'SiteTemplates', 'publish',
        array(
        'target'        => '/home/example/public_html',
        'source'        => '/usr/local/cpanel/3rdparty/share/site_templates/under_construction',
        'sitename'      => 'My Website',
        'description'   => 'I have a website now',
        )
);

 



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Publish a Site Publisher website.
my $templates = $cpliveapi->uapi(
    'SiteTemplates', 'publish',
    {
        'target'        => '/home/example/public_html',
        'source'        => '/usr/local/cpanel/3rdparty/share/site_templates/under_construction',
        'sitename'      => 'My Website',
        'description'   => 'I have a website now',
    }
);

 



<!-- Publish a Site Publisher website. -->
[% data = execute( 'SiteTemplates', 'publish', {'target' => '/home/example/public_html', 'source' => '/usr/local/cpanel/3rdparty/share/site_templates/under_construction', 'sitename' => 'My Website', 'description' => 'I have a website now.'} ); %]

 



uapi --user=username SiteTemplates publish target=%2Fhome%2Fexample%2Fpublic_html source=%2Fusr%2Flocal%2Fcpanel%2F3rdparty%2Fshare%2Fsite_templates%2Funder_construction sitename='My Website' description='I have a website now.'



{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  
      "transformed":1
   },
   "data":null,
}



Parameters

ParameterTypeDescriptionPossible valuesExample

target

or

docroot

string

Required

The directory that will contain the Site Publisher website.

The absolute path to the desired domain's document root./home/example/public_html
sourcestring

The desired template's source directory.

If you do not specify a value, the system uses the path and template values to determine the template's source directory.

You must include either the source parameter or the path and template parameters. 


The absolute path to a template directory that exists in one of the following directories:

/usr/local/cpanel/3rdparty/share/site_templates/under_construction
pathstring

The directory that contains the template's source directory.

You must include either the source parameter or the path and template parameters. 


/usr/local/cpanel/3rdparty/share/site_templates/
templatestring

The template's directory's name.

You must include either the source parameter or the path and template parameters. 


 A valid string.under_construction
parameter_namestring

The template's variables and values.

  • Use each variable's name as a parameter name for a parameter and value pair.
  • The template that you specify determines the values to define. You must include the appropriate data for the selected template.
    • If you use a cPanel-provided template, read our Guide to Site Publisher Templates documentation for more information.
    • If you use a third-party template, consult that template's documentation or its meta.json file.


A valid string.

My Website

Returns

This function only returns metadata.