usecuecms
Demo Login

Instant publishing

Instant publishing is a setting that allows you to publish pages directly (instead of via the dashboard). Turning instant publishing on requires the four steps below. If you just do step 1, you will get side-by-side editing AND instant publishing, but you will not be able to navigate the CMS using the live website. Therefore it is recommended to follow all steps below.

Note that everything that is not an actual page will still trigger an ’normal’ update through the dashboard. Pressing the publish button on a page will not only publish the page you are on, but will also publish all other changed that are staged for commit.

1. Turn the feature on

Turn the feature on by clicking on your name in the top right corner in the CMS and selecting ‘yes’ under ‘instant publishing’.

2. Add the home.json

Add a home.json file in the root of your layouts folder, containing this:

loadJsonForCMSLookup({{- $pages := slice -}}
{{- range .Site.AllPages -}}
  {{- $path := `` -}}
  {{- with .File -}}{{ $path = .Filename }}{{ end -}}
  {{- $path = replace $path hugo.WorkingDir `` -}}
  {{- if $path -}}
    {{- $pages = $pages | append (dict "permalink" .Permalink "path" $path) -}}
  {{- end -}}
{{- end -}}
{{- $pages | jsonify -}});

3. Change the config

Add this to your hugo.yml file:

outputs:
  home:
    - html
    - rss
    - json

Add this to the footer of your baseof.html file:

<script>
    if (window.location !== window.parent.location) {
        const script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'https://cms.usecue.com/js/monitoriframe.js';
        document.body.append(script);
    }
</script>