In-Website Edit Button

You can display an edit button on your live website only for your writers. This will allow them to easily jump from the live website to the prismic.io writing room to edit a page.

Before configuring an edit button, make sure that your site is configured for previews. It is a requirement for the edit button functionality.

Declare the endpoint for your repository in your HTML code

  • pug
  • html
Copy
script.
  window.prismic = {
    endpoint: 'https://<your-repository>.prismic.io/api'
  };
script(src='//code.jquery.com/jquery-2.1.1.min.js')
script(type='text/javascript', src='//static.cdn.prismic.io/prismic.min.js')
Copy
<script>
  window.prismic = {
    endpoint: 'https://<your-repository>.prismic.io/api'
  };
</script>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="//static.cdn.prismic.io/prismic.min.js"></script>

Include your document IDs

Where you want to have an edit button inserted, add a data-wio-id attribute to the DOM container corresponding to your document. You can have several edit buttons on the same page.

  • pug
  • html
Copy
article(data-wio-id='{insert document id}')
  //- Article content...
Copy
<article data-wio-id="{insert document id}">
  (...)
</article>

The prismic toolbar will add a link inside the tag. You're free to style it as you want to integrate it in your design.