How to generate preview deploys without a pull request?

  • netlify site name: Example:
  • custom domain:
  • Build problems: None
  • Did you try our generative AI chatbot, before posting? YES

Hi! I understand that deploy-previews are built when doing pull requests and merges at the upstream repo. But how can I generate both production + preview deploys at the same time from the current branch (e.g. triggered by a normal commit in continuous deployment).

My site is generated by HUGO, and in my netlify.toml I have both commands to build/deploy for production and for previews (see below).

Essentially I’d like to use deploy-previews to see future posts and posts labeled as “drafts” in my site.

But in my netlify dashboard I don’t see where these previews are deployed or can be seen, or if I need to to anything else to get this done.

  command = "hugo --gc --minify -b $URL && npx pagefind --source 'public'"
  publish = "public"

  HUGO_VERSION = "0.119.0"

  HUGO_ENV = "production"

  command = "hugo --gc --minify --buildFuture --buildDrafts -b $DEPLOY_PRIME_URL && npx pagefind --source 'public'"

  command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"

Because I am the only developer, and there is only a single branch in the repo, there is really no need to do branching or pull requests. Can netlify build the previews as specified in context.deploy-preview?

Thanks in advance for any help. Best – fernan

You are not going to be able to do this without actually using a branch or pull request. Your build for the commit into a production branch (example: main) will only have one build.

See: Deploy Previews | Netlify Docs

The base branch must either be a production branch, or a branch that has branch deploys enabled.

There is a permalink on each commit associated with that commit into the production branch, but it’s just the snapshot of that build.

To see a deploy-preview, you will need to create a branch make your changes and do a pull request or merge request into the production branch.

The easier way is just setup a branch and have branch deploys enabled. Site deploys overview | Netlify Docs

If using custom domains using Netlify DNS

Set up automatic deploy subdomains to ensure deploys are accessible

You also can read the docs at the link above to setup a subdomain for a branch to be able to see the latest draft deploy if you wanted to always see what’s deployed on that branch. (requires Netlify DNS to be managing a custom domain for your site)

1 Like