001: Hello world
A minimal Piko page that renders server-side data with scoped CSS. This is the simplest possible Piko application. A single .pk file demonstrates how the template, Go script, and style sections work together.
What this demonstrates
- The three sections of a
.pkfile:<template>,<script>, and<style> - Every
.pkpage must have aRenderfunction and aResponsestruct Renderreceivesr *piko.RequestData(the HTTP request) andprops piko.NoProps(none for pages)- It returns a
Response(becomesstatein the template),piko.Metadata, and anerror - Text interpolation with
{{ }}syntax. HTML-escaped by default piko.Metadatafor setting the page title and description- The filename determines the URL path:
pages/index.pkserves at/ - CSS in the
<style>section is automatically scoped to this page
Project structure
src/
pages/
index.pk The page: template + Go script + CSS
How to run this example
In the root directory of the Piko repository:
cd examples/scenarios/001_hello_world/src/
go mod tidy
air
See also
- PK file format reference for the structure used here.
- Tutorials: Your first page for the same pattern with explanation.