GateCheck

How to Stop Bots on a Static Site

A static site can use a visitor check without adding a traditional application server. The important question is what you need to protect: a public page from nuisance traffic, or information that must not be sent until a request is approved.

Published

Understand what a static page can protect

A static host serves files such as HTML, CSS, images, and JavaScript. A browser-side check can ask a visitor to wait, pass, solve a CAPTCHA, or be blocked before the page is shown in a normal browser. This can help reduce unwanted browser traffic without moving a small site to a different hosting platform.

It cannot make a file secret after the host has sent it. A visitor can inspect downloaded HTML or request a public file with a command-line client that does not run JavaScript. Do not put credentials, private records, or other confidential information in a static page and expect a browser check to protect it.

Choose where the decision should happen

For a public page where the goal is to screen ordinary browser visits, a small script in the page head is often the simplest starting point. GateCheck provides a one-line install for static sites, including GitHub Pages, Netlify, and Vercel. The page waits for the visitor check before it appears.

If the page itself must not be sent to a visitor until the request is allowed, the decision has to happen before the host returns that page. That means using a server check or an edge worker in front of the content. Static hosting alone does not provide that server-side boundary; check what functions or edge features your host offers before designing around them.

Add the browser check

Create a site in GateCheck and copy the script tag shown for that site. Put it at the top of the head on every page you want to check, before scripts that depend on the page being visible. Use the public key from the generated snippet; secret keys belong on a server and must not be copied into browser code.

The tag is three lines: a style that keeps the page hidden until the visitor is checked (it also stays hidden if the script is blocked), the script itself, and a line that shows browsers with JavaScript turned off a short message instead. That last line is plain CSS rather than a redirect, so crawlers that read your HTML without running scripts still see your page. Use the key from your dashboard rather than the example value.

<head>
  <style id="gatecheck-hide">html{visibility:hidden!important}</style>
  <script src="https://gatecheck.me/shield.js?key=YOUR_PUBLIC_KEY"></script>
  <noscript><style>html{visibility:visible!important}body>*{display:none!important}body::before{content:"This website needs JavaScript to check your visit. Turn it on and reload the page.";display:block;padding:24px;font:16px/1.5 system-ui,sans-serif}</style></noscript>
</head>

Test the result before relying on it

Check the page as an ordinary visitor, then test a visit that should receive a CAPTCHA and a visit that should be blocked by your rules. Confirm that a visitor who passes returns to the page, and that your own browser can still reach the page after the test. Review the traffic log so you can see which decision was made.

Test JavaScript-disabled behavior too. A browser script cannot run when JavaScript is unavailable; GateCheck documents a way to send those visitors to an explanation page. Check your site at narrow widths and with keyboard navigation after adding any new markup. Keep the script on a small test page first if you are unsure how it interacts with the rest of the site.

  • Confirm ordinary visitors can reach the page.
  • Check the CAPTCHA and blocked outcomes, including the return path.
  • Review the visit in the dashboard and verify the decision matches your rules.
  • Test the page with JavaScript disabled and at mobile widths.

Decide what should happen when the check is unavailable

A page that stays hidden until a check answers has a trade-off: people may wait if their connection to the service is slow or unavailable. GateCheck normally shows the page after a short timeout if it cannot complete a check. A fail-closed setting can keep the page hidden instead, but that can also keep legitimate visitors out during an outage.

Try the watch-only setting while you learn how your rules classify traffic. Watch-only records decisions without stopping visitors; it is not protection against the requests it records. Once you understand the traffic and the cost of a false block, choose a behavior that fits the page and your visitors.

Use a server or edge check for private content

If an endpoint returns account data, a download, or a page that must stay private, check the request on the server before returning the protected response. GateCheck documents an API and middleware examples for server-side checks. An edge worker can provide a boundary for some static-hosting setups, but it must run before the private response is sent.

Keep the secret key in the server or worker environment, validate the result there, and decide explicitly what to do if the check cannot be reached. Do not send a secret key to the browser or treat a hidden page as a substitute for authorization. A visitor check is one layer for abusive traffic; access control still belongs at the system that owns the data.

When a browser check is enough

For a public portfolio, hobby project, or information page, reducing automated browser traffic may be all you need. A short script can be easier to maintain than adding an application server just for a small site. Keep your content public if it is sent to every visitor, and make sure the check does not stand between search crawlers and pages you want indexed.

If you need to protect a form, account, API, or private response, pair the browser check with controls at the server that handles that action. The right setup depends on what the content is, how it is hosted, and what happens when a check is wrong. The GateCheck docs explain the script and server options.

Related guides