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.
Create, set the URL, write the template, activate, open
-
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: pickBuild a Web Page. You get anew web page, aweb renderand acurrent requestblock, already wired, and the URL field opens. -
Set the URL
Type
helloand pressSave. Leave out the leading slash. The URL now shows on the block: press it to change it. -
Make it public
Click the lock icon on the
new web pageblock and pick*public. -
Write the template
Press
Write templateon theweb renderblock. Paste this in the editor that opens and pressSave 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> -
Add the values
Drag out of the
titlepin into an empty area and add avalueblock holdingHello. Do the same fordescription, withMy first RUAL web page.Then press+ pinon the render block for a custom pin namedgreeting, and give it avalueblock holdingWelcome. -
Save
Press
Savein the bottom bar, orCmd/Ctrl + S. Saving is what publishes: from that moment visitors get the new version. -
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. -
Open the URL
Open
https://your-cluster/hello, or pressViewon thenew web pageblock, and view the page's source. Your template is there, inside a complete document.
What each setting does
- The URL is the block's
eventsetting, without the leading slash.hellois/hello,/is the home page, and a segment likeproducts/:slugarrives on the block'sparamsout-pin. The URL field lowercases what you type,:namesegments included, and refuses a URL that is already in use. - The scopes say who may open it.
*publicis everyone. A page with no scopes at all is closed: it opens for developers only, and other visitors are sent to sign in. web_renderanswers the request. Itsconnectioncomes from thecurrent requestblock, and the flow reaches it from the page's flow output.- The template is HTML with
{{mustache}}values.Write templatekeeps it on the block itself, in itshtmlsetting. To share one between pages, store the template and set the block'stemplatepin to{{> its-name}}. The text on the block is used only when that pin gives no value. titleanddescriptionfill the head of the page for you, and the template can print them too.greetingis a custom pin: a value of your own. A custom pin namedgreetingis{{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 thedatapin: its fields become variables by name.
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.
-
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. -
Switch to Code
Use the
Canvas|Codeswitch in the blueprint header. When your header has no such switch, your Studio does not include the code view yet. -
Paste the source
Replace the text in the editor with this.
eventandscopesare the settings above, the template goes on the block'stemplatepin here, andcustom_pinslists the pins of your own.Hello pageblueprint "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"}]} } -
Check
Press
Check(Cmd/Ctrl + Enter). It should say Compiles cleanly. -
Stage to canvas
Press
Stage to canvas(Cmd/Ctrl + S), then switch back toCanvasto 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:
<!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 see | Why | Do this |
|---|---|---|
URL is already in use in the URL field | Another page holds this URL. The message names its blueprint. | Pick another URL, or free this one first. |
A login page, or a redirect to /login | The 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 in | No 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 page | You 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 block | The 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 rendered | The 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 empty | The 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.