Skip to content

Static publisher

Important

The static publisher is still in early release, and may be subject to changes.

The static publisher is an add on to uSync.Publisher that allows you to publish your Umbraco site as a static collection of files.

installation

you can install the static publisher from NuGget

install-package uSync.Publisher.Static

Configuration

In order to use the static publisher you will need to configure it for your server in the usync.publish.config file

Change the Server Publisher

Under the relevant <server> section of the config add a <publisher> value of static:

<publisher>static</publisher>

This tells uSync.Publisher to use the static publisher for this server

Add a Deployer

You then need to tell the static publisher where to publish your files - This is done by configuring a 'deployer' - out of the box the static publisher has three deployers.

FTP

deploys files and media to the ftp server defined

<deployer alias="ftp">
    <server>your-ftp-server.com</server>
    <username>ftp-username</username>
    <password>ftp-password</password>
    <folder>/site/wwwroot</folder>
</deployer>

SFTP

Deploys files and media to the sftp server defined

<deployer alias="sftp">
    <server>your-sftp-server.com</server>
    <username>your-username</username>
    <password>your-password</password>
    <folder>/folder-path</folder>
</deployer>

Folder

Deploys to a local (or mapped) folder on the computer running the Umbraco site.

<deployer alias="folder">
    <folder>C:\Source\Testing\StaticPublish</folder>
</deployer>

Example

so, for example, an ftp deployment for a server may have the .following setup.

    <server alias="staticSite" enabled="true" pullEnabled="false" 
        url="http://example.com" >
      <name>Static Site</name>
      <icon>icon-sunny color-purple</icon>
      <description></description>
      <deleteMissing>no</deleteMissing>
      <groups>admin,editor</groups>

      <!-- a static deployment -->
      <publisher>static</publisher>

      <!-- ftp deployer settings -->
      <deployer alias="ftp">
        <server>ftp.example.com</server>
        <username>username</username>
        <password>password</password>
        <folder>/site/wwwroot</folder>
      </deployer>
    </server>

Adding additional deployers

You can write a deployer for Static publisher by implementing the uSync.Publisher.Static.ISyncStaticDeployer interface.

public interface ISyncStaticDeployer
{
    string Name { get; }
    string Alias { get; }

    Attempt<int> Deploy(string folder, XElement config, SyncUpdateCallback update);
}

The static publisher will calculate and build the static site in a temp folder and then pass this to the deploy method of the configured deployer.

The deploy method, accepts the following

parameter note
folder path to the location of the static files for the site
config xml of the deployers config (the deploy section)
update the uSyncUpdateCallback method used to pass update messages to the uSync UI.