Sets the page's title.
Setting a proper title
is important to let search engines determine the topic of your page.
Note:
You should always set the title inside the onReady()
event handler to
ensure search engines can read it.
function setTitle(title: string): Promise<void>;
The title to set.
import { createClient } from "@wix/sdk";
import { site } from "@wix/site";
import { seo } from "@wix/site-seo";
const wixClient = createClient({
host: site.host(),
modules: { seo },
});
// ...
document.addEventListener("DOMContentLoaded", async () => {
try {
await wixClient.seo.setTitle("New Title");
console.log("title set");
} catch {
console.log("failed setting title");
}
});
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.