Embed code to a specific form

Got it. If you decide to continue with the static site embedding Anvil forms, then you need some way in the URL to say which form you want to embed. With Anvil, you need to use hash routing.

There’s a hash routing dependency that’s overkill for what you want, but might be worth checking out.

The basic idea, though, is to use a startup module instead of a startup form, and in that module look for the hash part of the URL and open the right form based on that. Documentation on accessing the hash part of the URL is here: Anvil Docs | Navigation

Or, you can go the route Owen mentions, creating the entire site in Anvil. In that case you do want the hash routing dependency as that allows each form to have a distinct URL: HashRouting: Routing, navigation with URL Hash

A third possibility is to use Anvil for the backend via HTTP endpoints, and build the front end in Javascript in an otherwise static HTML page. I did this for one project that needed a shopping cart in the static site, and it works but requires you muck about in Javascript.

2 Likes