Manage content in HTML files.
HTML files can only be opened in the Visual Editor and Source Editor. There are two ways to give your editors access to manage content in the HTML.
Editable Regions have yellow borders in the Visual Editor indicating what areas are updatable. Define large sections to give full control or limit access by defining select images and text elements. Depending on what element the editable is applied to, editors will see different options in the editor.
To define an Editable Region:
class="editable"
to the HTML element. If the element already has a class you can append the editable class, for example: <div class="content editable">
The Visual Editor supports JavaScript. However, HTML rendered with JavaScript is not editable.
Editor Links allow you to link to other sections of the CloudCannon interface from within the Visual Editor. Use them to create edit buttons for your collection items and blog posts that are not visible on your live site. You can also add front matter Editor Links to open the front matter Editor at specified fields.
Editor Links are prefixed with cloudcannon:
and match the URL structure of the CloudCannon app, for example:
<a href="cloudcannon:collections/_staff/">
Edit all staff
</a>
<a href="cloudcannon:collections/_staff/jane-doe.md">
Edit Jane Doe
</a>
<a href="cloudcannon:collections/_posts/2015-07-30-welcome-post.md">
Edit Welcome Post
</a>
<a href="cloudcannon:status">
Link to Site Status and Recent Activity
</a>
<!-- Replace 'content' with your content directory -->
<a href="cloudcannon:collections/data/staff/">
Edit all staff
</a>
<a href="cloudcannon:collections/data/staff/jane-doe.md">
Edit Jane Doe
</a>
<a href="cloudcannon:collections/content/posts/2015-07-30-welcome-post.md">
Edit Welcome Post
</a>
<a href="cloudcannon:status">
Link to Site Status and Recent Activity
</a>
Front matter Editor Links are prefixed with cloudcannon:#
and match the Liquid format used to reference them, for example:
<!-- Inputs -->
<a href="cloudcannon:#title">
Edit the title
</a>
<!-- Arrays -->
<a href="cloudcannon:#array[1]">
Edit the first array item
</a>
<a href="cloudcannon:#array[+]">
Create a new item in an array
</a>
<!-- Inputs within an Object -->
<a href="cloudcannon:#object.title">
Edit a variable within an object
</a>
<a href="cloudcannon:#object.array">
Edit an array within an object
</a>
<!-- Inputs within an Array inside an Object -->
<a href="cloudcannon:#object.array[0].title">
Edit the title of the first array item within an object
</a>
Instead of only anchor tags, any element can have an Editor Link by using the data-cms-editor-link
attribute, for example:
<h1 data-cms-editor-link="cloudcannon:#title">
HTML
</h1>
To have edit links for posts in a list, add an Editor Link in the blog post loop:
<ul class="blog-posts">
{% for post in site.posts %}
<li class="blog-post">
<h3>{{ post.title }}</h3>
<p>{{ post.excerpt }}</p>
<a href="{{ post.url }}">Read more</a>
<!-- Editor Link -->
<a href="cloudcannon:collections/{{ post.path }}" class="editor-link">Edit post</a>
</li>
{% endfor %}
</ul>
<ul class="blog-posts">
{{ range .Pages }}
<li class="blog-post">
<h3>{{ .Title }}</h3>
<p>{{ .Summary }}</p>
<a href="{{ .RelPermalink }}">Read more</a>
<!-- Editor Link -->
<a href="cloudcannon:/collections/content/{{ .File.Path }}" class="editor-link">Edit post</a>
</li>
{{ end }}
</ul>
To have an edit link on a collection item page, add the following to the page:
<a href="cloudcannon:collections/{{ page.relative_path }}" class="editor-link">Edit</a>
If you are using a custom collections_dir
include site.collections_dir
in your editor link:
<a href="cloudcannon:collections/{{ site.collections_dir }}/{{ page.relative_path }}" class="editor-link">Edit</a>
When generating Editor Links in Jekyll, collection items should use relative_path, while posts and pages should use path.
<a href="cloudcannon:collections/content/{{ .File.Path }}" class="editor-link">Edit</a>
replace ‘content’ in the href
with the name of your content directory.
To show Editor Links inside the editor and hide them on the live site:
.editor-link
)..editor-link {
display: none;
}
.cms-editor-active .editor-link {
display: block;
}
CloudCannon adds the .cms-editor-active
class to the body of your site in the Visual Editor. The class is not on the live site.
Front matter can be highlighted within the sidebar or displayed standalone in a modal popup. To change how an editor link opens:
data-cms-editor-link-style
attribute<a href="cloudcannon:#title" data-cms-editor-link-style="modal">
Edit the title
</a>
<h1 data-cms-editor-link="cloudcannon:#title" data-cms-editor-link-style="modal">
HTML
</h1>
Using modal-style editor links that point directly to hidden fields show the field in the pop up.
You can give Editor Links our default styles by adding the cms-editor-link
class. This provides a seamless experience alongside Editable Regions by using the same styles.
<a href="cloudcannon:#title" class="cms-editor-link">
Edit the title
</a>
<h1 data-cms-editor-link="cloudcannon:#title" class="cms-editor-link">
HTML
</h1>
cms-editor-link-dirty
is also handled with the default styles.
Set the default path to load when the Update Home action is clicked in the Dashboard.
Configured globally in _config.yml
with an _editor
object:
_editor:
default_path: /about/
Configured within the params
of your site’s config:
[params._editor]
default_path = "/about/"
Clicking the Update Home Dashboard action will load the default_path
. The example above will load /about/
instead of loading the default of /
.