Getting started
Your first static site
A start-to-finish tutorial: from a new Umbraco site with a starter kit to a generated static copy that you deploy to a folder on your own machine and view in a browser. It takes about fifteen minutes and doesn't need an account with any hosting provider. If you already have an Umbraco 18 site, skip to step 2.
Before you start
You need the .NET 10 SDK and, to view the result at the end, either Node.js or Python. The steps use the command line, but you can do the same in Visual Studio or Rider.
1. Create an Umbraco site with a starter kit
xStatic renders your real Umbraco pages, so you need a site with templates and some published content. The Clean starter kit gives you both.
dotnet new install Umbraco.Templates::18.3.2
dotnet new umbraco --name MyStaticDemo
cd MyStaticDemo
dotnet add package clean
dotnet rundotnet run prints the address the site is listening on, for example https://localhost:44359. Open it and follow
the Umbraco installer to create your first user. That user is the root user, and it is the one xStatic gives access
to in the next step.
When the installer finishes, Clean adds its sample content and templates. Browse the front end to check the pages render. If the content tree shows unpublished pages, publish them, because xStatic only generates published content. Then stop the site.
2. Install xStatic
dotnet add package xStatic
dotnet runThere is no code to add. Sign in to the backoffice as the root user and open the xStatic section. If the section is missing, see Installation.
The section has several tabs. You will use three of them here: Deployment Targets, Export Types and xStatic Sites. The Backoffice tour covers the rest.
3. Create a deployment target
A deployment target says where finished files should go. Here that is a folder on your disk.
- Open the Deployment Targets tab.
- Click Manually Configure New Deployment Target.
- Set Name * to
Local folder. - Set Deployer * to File System. The Configuration panel under it fills with the deployer's fields.
- Set Folder Path to an empty folder, such as
C:\Temp\my-static-siteon Windows or/tmp/my-static-siteon Mac and Linux. xStatic creates the folder if it doesn't exist. - Click Submit.
A card named Local folder appears. The Deployment Targets tab is only visible to users in the xStaticAdmin
group, because targets can hold passwords. See Deployment targets.
4. Check the export type
An export type chooses how pages are turned into files. xStatic adds one called HTML Website when it first starts, and that is what you want for a normal static site. Open the Export Types tab to see it. You don't need to change anything. Export types explains the options.
5. Create the site
Open the xStatic Sites tab.
Click Create new static site.
Fill in the dialog:
Field What to enter Site Name * My static demoRoot Node * Click Choose and pick the top Home node of your content tree Media Root Nodes Click Choose and pick the media folders your pages use, or the whole media library for this demo Export Format * HTML Website Deployment Target Local folder Leave the other fields as they are. Cultures, Asset Paths, Image Crops, Post Generation Actions, Auto Publish and Target Hostname are all optional. The Sites page describes each one.
Click Submit.
A card for My static demo appears with the root node's path, Exports as HTML Website, Manual Deploy, and the notes This site has never been built. and This site has never been deployed.
6. Generate the site
- On the card, click Generate.
- A progress bar replaces the card while xStatic works. xStatic fetches every published page from the running site, copies the media you chose, and stores the result.
- When it finishes, the card shows Last generated on with the date and time and a Size line, and the Clean and Download buttons appear.
If some items failed, a warning notification says Site generated with N problem(s) and lists up to five of them. The pages that worked are still stored. See Generating and deploying for how to read the results.
The generated files are kept in your Umbraco project at umbraco/Data/xStatic/output/{site id}. The first site you
create is usually site 1. Open it and you will see one index.html per page, each in a folder named after the page's
URL, plus a media folder:
umbraco/Data/xStatic/output/1/
index.html
about/index.html
blog/index.html
media/...You can click Download at any point to get everything as a zip file instead.
7. Deploy to the folder
- On the card, click Deploy.
- Confirm in the Deploy Site dialog by clicking Deploy.
- When it finishes, the card shows Last deployed on with the date and time.
The File System deployer copies the generated files into the Folder Path you set, overwriting files that already exist. It does not delete anything that is already in that folder. Deploying to a folder has the details.
8. View the static site
Your deployed folder is a complete website. Serve it with any static file server:
cd C:\Temp\my-static-site
npx serveor, with Python:
cd /tmp/my-static-site
python -m http.server 8080Open the address it prints. You are now looking at a copy of your Umbraco site that needs no Umbraco, no database and no .NET to run. Stop the Umbraco site and refresh to prove it.
Static servers can't run your Umbraco forms or search, so anything that relies on server code won't work in the copy. What is xStatic? covers what to expect.
Troubleshooting the first run
- The xStatic section isn't there. The user isn't in a group with access. See Installation.
- There is no Deploy button. The site has no Deployment Target. Edit the site and choose one.
- Pages fail with a download error. The site must be running and reachable at the address Umbraco generates for
each page. On Mac or Linux with a self-signed certificate, set
XStatic:TrustSslWhenGeneratingtotrue. See Troubleshooting. - The static copy has no styling or scripts. CSS, JavaScript and fonts that live on disk rather than in the media library are only copied if you list them under Asset Paths. View the page source to find their paths, then see Asset paths.
- Links in the static copy point at
localhost. Set Target Hostname on the site to the hostname you will publish on, such aswww.example.com, then generate again. This only replaces hostnames that are set in Umbraco's Culture and Hostnames, so add your local address there first. See Sites.
Next steps
- Put the site on the internet with Netlify, Git or FTP.
- Rebuild automatically when editors publish: Auto publish.
- Include CSS and scripts that live outside Umbraco's media library: Asset paths.
- Make resized images: Image crops.
- Watch the xStatic 14 - Get Started video for the same flow on screen.
