Easily restore your project to a previous version with our new Instant One-click Backup Recovery

Hygraph
Docs

Working with preview URLs

#Overview

Preview URLs are automatically generated links that allow you to preview content in your frontend before it's published.

#What you can do

Configuring this feature adds a button to the Content Editor's right sidebar, so editors can quickly access content previews.

#Create a preview URL

Create a Preview URLCreate a Preview URL

  1. Navigate to the Schema builder.
  2. Select the model you'd like to create a preview URL for.
  3. Click on the sidebar tab, located at the top of the screen, under the title of the selected Model.
  4. Select the Preview widget from the right sidebar.
  5. A screen will pop up, where you can complete the Preview name and the URL template fields. This is where you can add your own website URL and specify how the preview slug should be constructed from field values in the content entry. You can add multiple preview URLs by clicking on the + Add more button located at the bottom of the screen. So you could, for instance, add a preview URL for development and another for staging. Here you can find some information on how to define your own preview URLs.
  6. Click on Save.

If you then navigate to the Content Editor and access content that uses the model where you included the preview URL, you will be able to see the link under the Preview menu in the right sidebar. Click on this link to access the preview.

Preview URL in content editorPreview URL in content editor

If you configured more than one preview URL for that model, you will be able to select the one you want by using the dropdown.

#Delete a preview URL

Create a Preview URLCreate a Preview URL

  1. Navigate to the Schema builder.
  2. Select the model that contains the preview URL that you want to delete.
  3. Click on the pencil icon of the preview URL widget to edit it.
  4. Click on the trash icon located at the end of the line of the preview URL that you want to eliminate.
  5. Click on Save.

#How to define a preview URL

During the process of creating a preview URL, you will be prompted to complete the Preview name and the URL template fields. Complete the Preview name field with a name that will help you identify the preview URL in the Content Editor later.

The URL template field is where you will define how the URL should be built, using field values from the content entry. The exact way each preview URL will be built will depend on your website's URL structure. Typically, you will start with your domain, then a section such as a blog. Finally, you will use handlebars notation to include a field that is unique to the content you want to preview, to be used as an identifier.

Define a Preview URLDefine a Preview URL

As soon as you type in the open curly brace, a list will display showing all the available fields - also included above under the Available fields screen section. You can use more than one of the available fields, if needed.

#Resources