In this project, we provide all the code you need for a personal website with a homepage, information pages, and navigation. Let's see how to set up Prismic to get this up and running.
Install the Prismic CLI
Make sure to first install npm on your machine, if you don't already have it.
Fire up a terminal (command prompt or similar on Windows) and run the following command.
npm install -g email@example.com
In the terminal, navigate to where you want to launch your project and run the following command.
prismic theme --theme-url https://github.com/prismicio/nextjs-multi-language-site --conf prismic-configuration.js
prismic theme command will initialize a Next.js project and connect it to your newly created repository. The command will end by displaying a link to your content repository backend in the form of https://your-repo-name.prismic.io.
Using Next.js Internationalized Routing
For both you just need to update your i18n settings in the
defaultLocale will match the languages in your new Prismic repo. So. if you modify the languages of your repository make sure you also update them here. Right now your settings right now should look like this:
locales: ['en-us', 'fr-fr'],
In this example the generated routes would be:
/en-usfor the English master locale
/fr-frfor the French locale
Thanks to Next.js Language Detection, the "
/" route will be based on the
Accept-Language header, which all modern browsers support.
Read Next.js official documentation about Internationalized Routing to learn more.
Run the app
Now it's time to see things working! Go back to terminal, point it to your project location and run:
npm run dev
This will launch a local development server at http://localhost:3000.
Deploys made easy with Vercel
With Prismic and Next, it's incredibly easy to deploy a blazing-fast, dynamic site. Learn how to deploy a statically-generated Next site for free on Vercel in three easy steps:
- Sign up to Github and push your project to a new repository
- Sign up to Vercel and Import your project
- Then just click Deploy, wait a bit for the project to build and then your site will be live!
You may need to add more configuration if you included any statically generated pages in your project. If so, you need to set up webhooks to update those pages when there are changes in your Prismic repo.
Setup the Preview feature
Customize to your liking
You should easily find what to modify in the code to customize the website: just edit the stylesheets and the templates to fit your design!
Just curious about the code?
If you aren't interested in recreating this project and would just like to look at the code then you can download the project here.