# How to make your section’s model preview URL dynamic

**URL:** <https://forum.builder.io/t/how-to-make-your-section-s-model-preview-url-dynamic/2636>\
**Category:** Technical Questions\
**Tags:** visual-editor, feature\
**Created:** [September 20, 2022, 5:07pm UTC](https://forum.builder.io/t/how-to-make-your-section-s-model-preview-url-dynamic/2636 "2022-09-20T17:07:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustavohgs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/gustavohgs/32/1965_2.png) [@gustavohgs](https://forum.builder.io/u/gustavohgs)\
**Post date:** [September 20, 2022, 5:07pm UTC](https://forum.builder.io/t/how-to-make-your-section-s-model-preview-url-dynamic/2636/1 "2022-09-20T17:07:37Z")

</div>

For example in blog posts you want the preview url to be based on the `slug` property on your section model.

Example: [https://example.com/jobs/`${jobId}`](https://example.com/jobs/%60%24%7BjobId%7D%60)

You should be able to preview your content and be able to handle multiple url parameters  
with the following configuration:

1 - Go to your model options where you can edit the preview URL\* for your model  
2 - At the right side of the input to preview Url, click the button with “\< \>”, which says “customize preview URL logic”  
3 - Now you will be prompted to a section where you can write whatever JS function you choose, make sure you always return a string as a URL

Example 1:

Let’s say you want to return a string based on a targeted audience by locale

```auto

 if (targeting.locales[0] === 'es') {
  return `https://mypreviewurl.com/some-spanish-content`;
 }

 return `https://mypreviewurl.com/general-content`;

```

or even:

```auto
 return `https://mypreviewurl.com/${targeting.locales[0]}${targeting.urlPath}`;

```

Example 2:

Let’s say you want to return a string based on a content data in your editor

```auto
 return `https://mypreviewurl.com/jobs/${content.data.jobId}}`;

```

And, as mentioned on the prompt:

```auto

/*

* Available objects:
* content: a json representation fo the current state of content. e.g. you can access things like `content.data.title`
* space: the current space settings, including properties like `space.publicKey`
* targeting: an object represeting the content targeting settings, for example: `targeting.urlPath`
* fetch: You can reun async code with `fetch`, such as: `const settings = await fetch('...');`
* contentModel: the current content model, including helper properties like `contentModel.isLive` to know if an item is live
* (published and not scheduled for a future or prior date)

*/

```
