Your First Web Page

Five minutes: create a blueprint, pick Build a Web Page, give the web_page a URL and the *public scope, write the template of the web_render, save, activate the blueprint and open the URL.

You need access to a cluster (see Getting Access) and the rights to edit blueprints.

No Build a Web Page in your Studio? Studio 3.3.0 and older do not have this option and cannot set a web page's URL on the canvas. Build the same page from source instead. A newer Studio hides the option only on a cluster without web pages.

Create, set the URL, write the template, activate, open

  1. Create the blueprint

    Open the blueprints overview in RUAL Studio and create a new blueprint. Type a name and press Next step. Studio asks What type of blueprint would you like: pick Build a Web Page. You get a new web page, a web render and a current request block, already wired, and the URL field opens.

  2. Set the URL

    Type hello and press Save. Leave out the leading slash. The URL now shows on the block: press it to change it.

  3. Make it public

    Click the lock icon on the new web page block and pick *public.

  4. Write the template

    Press Write template on the web render block. Paste this in the editor that opens and press Save Changes (Cmd/Ctrl + S). That keeps the text on the block and publishes nothing yet.

    Template
    <main><h1>{{title}}</h1><p>{{greeting}}, this page was rendered on the server.</p></main>
  5. Add the values

    Drag out of the title pin into an empty area and add a value block holding Hello. Do the same for description, with My first RUAL web page. Then press + pin on the render block for a custom pin named greeting, and give it a value block holding Welcome.

  6. Save

    Press Save in the bottom bar, or Cmd/Ctrl + S. Saving is what publishes: from that moment visitors get the new version.

  7. Activate the blueprint

    Pages are inactive by default. The switch at the right of the top bar reads Inactive: click it. A new blueprint needs this once, and a page holds its URL only while its blueprint is active.

  8. Open the URL

    Open https://your-cluster/hello, or press View on the new web page block, and view the page's source. Your template is there, inside a complete document.

What each setting does

  • The URL is the block's event setting, without the leading slash. hello is /hello, / is the home page, and a segment like products/:slug arrives on the block's params out-pin. The URL field lowercases what you type, :name segments included, and refuses a URL that is already in use.
  • The scopes say who may open it. *public is everyone. A page with no scopes at all is closed: it opens for developers only, and other visitors are sent to sign in.
  • web_render answers the request. Its connection comes from the current request block, and the flow reaches it from the page's flow output.
  • The template is HTML with {{mustache}} values. Write template keeps it on the block itself, in its html setting. To share one between pages, store the template and set the block's template pin to {{> its-name}}. The text on the block is used only when that pin gives no value.
  • title and description fill the head of the page for you, and the template can print them too.
  • greeting is a custom pin: a value of your own. A custom pin named greeting is {{greeting}} in the template. Wire in what you need, such as a storage result. To hand over a whole object at once, wire it into the data pin: its fields become variables by name.
Adding a page to a blueprint you already have Right-click the canvas, choose Add new block, search for web page and pick new web page. Studio places the web render and current request blocks with it and opens the URL field, as in the steps above.

The same page from source

The Studio Code View gives you the same blocks from a few lines of text. Use it when you prefer source, or when your Studio has no Build a Web Page.

  1. Create an empty blueprint

    Create a new blueprint, type a name and press Next step. Close the What type of blueprint would you like dialog with the × in its corner. You now have an empty canvas.

  2. Switch to Code

    Use the Canvas | Code switch in the blueprint header. When your header has no such switch, your Studio does not include the code view yet.

  3. Paste the source

    Replace the text in the editor with this. event and scopes are the settings above, the template goes on the block's template pin here, and custom_pins lists the pins of your own.

    Hello page
    blueprint "Hello page"
    
    flow page = web_page with {event: "hello", scopes: ["*public"]} {
      web_render(
        connection: page.connection,
        template: "<main><h1>{{title}}</h1><p>{{greeting}}, this page was rendered on the server.</p></main>",
        title: "Hello",
        description: "My first RUAL web page.",
        greeting: "Welcome"
      ) with {custom_pins: [{id: "greeting", state: "greeting", type: "value"}]}
    }
  4. Check

    Press Check (Cmd/Ctrl + Enter). It should say Compiles cleanly.

  5. Stage to canvas

    Press Stage to canvas (Cmd/Ctrl + S), then switch back to Canvas to see the blocks wired together. From here, save, activate and open the URL as in the steps above.

The browser receives a complete document

Without a layout the page gets a plain HTML5 document around it, and the head tags are written for you from the pins:

View source on /hello
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello</title>
<meta name="description" content="My first RUAL web page.">
<link rel="canonical" href="https://your-cluster/hello">
<meta property="og:description" content="My first RUAL web page.">
<meta property="og:locale" content="en_US">
<meta property="og:title" content="Hello">
<meta property="og:type" content="website">
<meta property="og:url" content="https://your-cluster/hello">
<meta name="twitter:card" content="summary">
<script src="/static-chunks/rual-web-XXXXXXXXXX.js" nonce="..." defer></script>
<script type="speculationrules" nonce="...">...</script>
</head>
<body>
<main><h1>Hello</h1><p>Welcome, this page was rendered on the server.</p></main>
</body>
</html>

Start the template with <!doctype html> to write the whole document yourself, or name a layout. The head tags are written for you in every case.

When it does not work

You seeWhyDo this
URL is already in use in the URL fieldAnother page holds this URL. The message names its blueprint.Pick another URL, or free this one first.
A login page, or a redirect to /loginThe page has no *public scope, or no active page holds this URL yet.Check the scopes and the URL, and check that the switch reads Active.
A not found page while you are signed inNo active page holds this URL.Did you save, and does the switch read Active? A page of an inactive blueprint holds no URL.
you do not have access to this pageYou are signed in, without a scope the page asks for.Add the scope to your user, or to the page.
this page's flow does not reach a web render blockThe flow ended without a web_render, a web_redirect or an httpconnection answer.Connect the flow output of the page to the render block.
This page could not be renderedThe template does not compile, or there is no template.Open the page signed in as a blueprint developer: the reason is shown to you, and only to you.
A value stays emptyThe name in {{...}} does not match a custom pin or a field of data.A missing value prints nothing and is not an error. Compare the names.

Next steps

Tutorial: A Small Webshop Storages, lists, a product page, live search, a cart and a checkout. Template Syntax Conditions, loops, filters and the variables a template sees. Actions Make a button change one row without reloading the page.

Frequently asked

How do I make a public web page in RUAL?

Add a web_page block and set its event field to the URL without the leading slash, for example shop. Give it the scope *public, connect its flow to a web_render block, write the template there, and activate the blueprint.

Why does my RUAL web page answer a 500?

A page flow that ends without an answer is a 500 that says so. Check that the flow reaches web_render, or answers another way through an httpconnection block or web_redirect, and read the message if you are signed in as a blueprint developer: visitors only see that it failed.