Browse apps
Install
Author
Storyblok GmbH
Last update
2019-09-26
Advanced paths
Programmable preview paths

When installing this app you get a new field in the folder dialog which lets you define the “Real path”. Be aware that this will change the preview path of all your existing content items and you need to define the “Real path” for every folder manually.

The “Real path” is the path where the visual preview points to.

The app has been made for following scenarios:

  • You have root folders that should point to different preview domains
  • You have different preview domains based on the selected language
  • You have a url structure that uses other separators than slashes. Example: yoursite.com/folderxy-itemxy instead of yoursite.com/folderxy/itemxy
  • You have virtual folders. Example: yoursite.com/itemxy instead of yoursite.com/folderxy/itemxy

Templating syntax

The “Real path” is programmable with the templating engine Squirelly and following context is available:

Attention: The folder context variable is only available in the real path of the folder and not on the real path of the story.

  • story The object of the current
  • lang The currently selected language
  • branch_id The current branch id
  • env_location The current environment location
  • env_name The current environment name
  • folder The object of the folder of the path (ONLY available on the folder real path)

Following a few path template examples:

Use https://www.yoursite.de/ when the language is “de” and otherwise use https://www.yoursite.com/{{lang}}

{{if(options.lang == 'de')}}https://www.yoursite.de/{{#else}}https://www.yoursite.com/{{lang}}{{/if}}

Use the folder slug as “Real path”

{{folder.slug}}

Use a custom preview url only when the environment is not “Default”.

{{if(options.env_name == 'Default')}}https://www.yoursite.com/{{/if}}