Make a preview of this website, so I can look at the new layout without
visitors noticing anything.
A staging environment is a copy of your site where you are allowed to break things. It is the difference between "let me just try that plugin" on a site with visitors on it, and on a copy nobody visits.
We call it a preview, and it lives on preview.yourdomain.com. You create one per website from the overview in your hosting panel, or you ask the assistant for it.
What happens when you create one
A subdomain is created with its own folder, not a folder inside your site. Your site's files are copied there.
If it is a WordPress site, it also gets its own database: a copy of your current one, with every address inside the database rewritten to the preview address. That last part matters. Without that rewrite, your copy still points at your real site in links, images and settings, and then you spend your time looking at the wrong environment without noticing.
The preview gets a robots.txt asking search engines to stay away. That is not a guarantee, but it prevents the most common problem: your staging copy showing up in Google and competing with your real site for attention.
Creating it runs as a background job. On a large site that can take a while; the page updates itself.
What you can do with it
The preview is an ordinary site on an ordinary subdomain. So you can do anything there that you can do on your site, including logging into the WordPress admin and letting the assistant work in it.
Where we see it used most:
- a theme or plugin update you do not trust, there first;
- a new layout or a redesign, with the link going to a client or colleague;
- trying out a migration before you do it for real;
- tracking down a conflict you do not dare cause on the real site.
The assistant knows whether it is working on a preview or on the real site. It says so too, so you do not accidentally give an instruction with the wrong environment in mind.
Refreshing, publishing and throwing away
Refreshing pulls your site onto the preview again. So it throws away the changes on your preview; that is the point of it.
Publishing goes the other way: the files from your preview to your real site. That happens with a few precautions, and they are worth knowing:
- a snapshot or safety copy is made first, so you can go back;
- the copy does not delete anything on your real site that is no longer on the preview;
- two files never come along: your
wp-config.phpand yourrobots.txt. The first because it holds your database credentials, the second because otherwise you put the "stay away" from your preview on your real site; - your preview's database does not come along.
That last point is the most important one in this article, and it is deliberate. In WordPress, content lives in the database: posts, pages, settings, and with page builders your layout too. If you build a page on your preview and then publish, the files are on your site and the page is not.
So a preview is good for code, themes, plugins and files, and it is not meant for moving content. You build content on your real site, or you move it with the export function of the plugin that made it.
Throwing away removes the preview: the subdomain, the folder and the database. Do that when you are done. A forgotten six month old preview is a second, outdated site on your account, with outdated plugins, and that is exactly what scanners find interesting.
What to watch out for
The preview needs a DNS record. If your DNS is with us, that is taken care of. If your DNS is elsewhere, a record for preview.yourdomain.com has to be added, otherwise the address does not exist. The page checks that and says so when it is missing.
A new subdomain touches your certificate. This is a quirk of the hosting panel that is rarely written down anywhere: a certificate belongs to your account, and requesting one for a new subdomain can replace the existing one instead of extending it. So after creating a preview, check that your real site still has a valid certificate. If it goes wrong it is one action to request it again, but you want to know before a visitor tells you.
A preview is not a backup. It is a snapshot you overwrite yourself the moment you refresh. Your backups are elsewhere; see making and restoring backups.
Do not put real client data on a preview you share. A copy of your database is a copy of your client data. If you share the link widely, empty out what is not needed first.
Common mistakes
Building content on the preview and then publishing. The database does not come along. Your page stays behind.
Forgetting you are on the preview. Look at the address bar before you delete anything.
Leaving the preview up after use. That is a second site nobody updates.
Publishing your robots.txt. Then you ask Google to stay away from your real site. That is why that file does not come along here.
Using a preview as a backup. Refreshing throws away your only copy.
Not checking your certificate after creating one. A new subdomain can replace your account's certificate.
If you want to know what else the assistant can do inside a website, have a look at the Invoker Assistant. How to put a site live from a repository is in deploying a static site or Next.js with git.