Homepage
Set which page your site shows at /, with its header and footer, from the Pages panel, the Pages list or Site settings.
Your site's homepage is one of its pages. You build it in the Page Builder like any
other page, so it wears the site's header and footer, places components and has
everything a page has. Then you set it as the homepage, and visitors see it at /.
The homepage is experimental: the route option, the service and the admin controls may still change before they are marked stable.
Set the homepage
Only a published page can be the homepage. Set one from any of these places:
- The builder's Pages panel: open a page's ⋯ menu and choose Set as homepage…. The homepage is listed first, with a house in place of the page icon.
- The Pages list in the admin: the homepage's title has a Homepage badge beside it, and every row's menu has Set as homepage….
- Site settings (from Page settings, Site settings ▸): the Homepage menu lists your published pages.
Each one asks before it changes anything, naming the page and the homepage it replaces. On a page that is still a draft, Set as homepage… says "Publish this page first".
The homepage keeps its own address, such as /home. While it is the homepage, that
address answers with a permanent redirect to /, so links to it still land. If you set
another page as the homepage later, the page is served at its own address again.
Its Page settings show its address as /, with a Homepage badge and a line
saying which of its own addresses redirects there. Below it, Own address is the
address you edit, kept for when another page is the homepage. Its search result
preview shows / too, the address search engines are given.
Deleting and unpublishing the homepage
You can't delete the homepage: every Delete for it is unavailable with "Set another homepage first", and any other way of deleting it is refused with "This is the homepage. Set another homepage first."
You can unpublish it. The admin asks first, because / then shows "Page not found"
(or your site's welcome page, see below) until you publish it again or set another
homepage. Publishing it again makes it the homepage again; you don't set it twice.
In each language
On a site with several languages, the homepage is the same page in every language,
read in that language: at / for your default language and at /<locale> (as your
site's addresses are spelled) for each other one. Its own address in each language
redirects to that language's home root.
In search results and the sitemap
The homepage's address is its language's home root everywhere Nextly gives one. With the SEO plugin installed, its canonical link names the root, and the sitemap lists it at the root in each language it's published in, never at its own address. Setting another page as the homepage shows in the sitemap the next time it's read: the new homepage moves to the root, and the old one is listed at its own address again. While the homepage is unpublished, the sitemap doesn't list the root. Leaving the site with no homepage gives the root back to your site: the page returns to its own address, and no redirect is left from the root to it.
If another page of your site is already served at /, such as a Single whose address
is /, setting a homepage is refused with "Another page of this site is already served
at /, so this page can't be the homepage. Give that page another address first."
The same holds for a language you add later: the homepage takes that language's root the
next time the site starts or the page is saved, and a save is refused while another page
is served at that root.
Serve the homepage from your route
The homepage is served by the same route as your other pages: createContentPage or
createPublicContentPage over pageBuilderContent(), in an optional catch-all at
the root of your site, so it matches / as well as /about:
import { createPublicContentPage } from "@nextlyhq/blocks-react/next";
import {
pageBuilderContent,
pageBuilderLayouts,
} from "@nextlyhq/plugin-page-builder";
const route = createPublicContentPage({
...pageBuilderContent(),
pages: {
collections: ["pages"],
field: "content",
layouts: pageBuilderLayouts(),
},
// What / shows while no page is the homepage, or while it is unpublished.
home: {
fallback: () => <p>Welcome to your new site.</p>,
metadata: { title: "Welcome" },
},
});
export const { generateMetadata, generateStaticParams } = route;
export default route.ContentPage;You don't need a route file of your own for /. The route draws the homepage inside
its header and footer, names / as its canonical address, builds / ahead of time and
refreshes it when the homepage changes or is republished, with no deploy.
home.fallback is optional. Without it, / answers "Page not found" while there is no
homepage. home.metadata is the fallback's head, or a function answering it.
A site whose / is its own code
If your site serves / from a route file of its own, tell the Page Builder, so authors
aren't offered a choice your site never shows:
pageBuilder({ siteHomePage: "code" });The homepage controls then don't appear, and Site settings shows the homepage as "Served by your site's code".
From your own code
The plugin's homePage service reads and sets the homepage for server code of your
own, such as a seed script. It checks what may be set (a published page) but not who
is asking:
const service = nextly.plugins["@nextlyhq/plugin-page-builder"].homePage;
await service.read(); // the homepage's id, or null
await service.choose(pageId); // set it; null leaves the site with noneMove a homepage Single into Pages
A site that draws / from a Single (createSinglePage) keeps working exactly as it
did. To give it the site's default header and footer without moving it, pass
layouts: pageBuilderLayouts() to its route (see
Singles). To move it to a page, so it can choose
its own header and footer and place components:
- In the admin, create a page (for example Home) and copy the Single's blocks into it: open the Single in the builder, select all, copy, and paste into the page.
- Publish the page.
- Replace your
app/(frontend)/page.tsxand[...slug]route with the optional catch-all above. To keep the Single showing until you're ready, pass it as the fallback:home: { fallback: () => homepage.SinglePage(), metadata: () => homepage.generateMetadata() }, wherehomepageis yourcreateSinglePage(...)route. - Set the page as the homepage.
/now shows it. - When you no longer need it, remove the Single and the fallback.
A blocks field that holds placed components
A blocks() field that names the blocks it accepts (blocks: { allow: [...] })
accepts only those. core/* means every core block and nothing else: a placed
component's type is the engine's own, nextly/component-instance, so a field meant
to hold components names it too:
blocks({
name: "layout",
blocks: { allow: ["core/*", "nextly/component-instance"] },
});The builder offers only what the field accepts, in the Add panel, the in-place picker and the search. A save that holds something else is refused, naming it.