Disable branch-deploy preview

Hi All,

Is it possible to disable deploy-previews for branches? I already disabled deploy for the main/production branch (previews are are disabled for PRs) in the Netlify UI. For example, the staging branch would be deployed when pushed to the repository, but I would like to disable the deploy-preview.

If you’ve selected none, we should not be deploying a deploy preview at all. Is that not working? If so, can you share the site name?

Thanks for looking into this!
The site = a2ztherapyclinic.netlify.app. Production auto-publishing has been turned off. My use-case is to only have the branch-deploys enabled, with branch-deploy previews turned off.
For example, the branch deploy (name = staging), I can click the “Preview” button to see it. See attached image for reference. This will open https://65318844d2f1bd1d6d113ad3--a2ztherapyclinic.netlify.app/. I understand this as branch-deploy previews still being active, correct?

You cannot disable those previews. Those preview URLs exist for all deploys. That has nothing to do with deploy previews.

Cool. Thanks for sharing.
Would a simple redirect, in the _redirects file suffice as a workaround to force visitors to view the named (branch name) branch-deploy?

Sure, you can do that, but you’d have to do something like: Custom headers | Netlify Docs so you don’t add a redirect for your primary URL.

What would be a decent way of handling this?

I am trying to redirect all branch-deploy previews to the branch-deploy (name = staging) using the “_redirects” and “_headers” files.

For example:
page to redirect from: https://65356a4674bc170008bdabb7--a2ztherapyclinic.netlify.app/
page to redirect to: staging–a2ztherapyclinic.netlify.app/

I would like all pages to be redirected to the “staging–…” deploy.

Apologies for the “basic” questions - learning all this for the first time :blush:

Did you try:

https://65356a4674bc170008bdabb7--a2ztherapyclinic.netlify.app/*  https://staging–a2ztherapyclinic.netlify.app/:splat 301!

You’d have to know the deploy URL for that and generate the redirects for every delpoy. You can use shell scripts for that, or also use a Netlify Build Plugin if you wish to use JavaScript: Create Build Plugins | Netlify Docs

It’s not very straightforward to do, but also not very difficult. I do wonder if it’s really required though. Unless you’ve a very strong use-case, I’d not suggest you to spend your time on this.

Agreed! My use-case was to simply redirect all deploy-branch previews to the deploy-branch name (“staging–a2ztherapyclinic.netlify.app”.

In any case, thanks for the advice :+1: