Skip to main content
Mouhssine Lakhili

How I Built My Portfolio with Next.js and Vercel

How this developer portfolio is built today with Next.js 15, TypeScript, Tailwind CSS and Vercel: static pages, three languages without a reload, an MDX blog, metadata and structured data.

Mouhssine LakhiliUpdated 8 min readAlso available in FrançaisEspañol

Introduction

For a full-stack developer, a portfolio is where recruiters and clients check what you can really do. I started this one in January 2025 and it has changed a lot since. It now runs on Next.js 15 with the App Router, React 19, TypeScript and Tailwind CSS, deployed on Vercel, in English, French and Spanish.

This article describes the site as it is today, not as it was at launch. The code comes from the repository, shortened where needed. Updated in November 2026.

Why Next.js?

Static generation

A portfolio does not need to compute its pages on every visit. Each page is generated at build time from its route and its content:

typescript
// app/[locale]/blog/[slug]/page.tsx
type Props = { params: Promise<{ locale: string; slug: string }> };

export const dynamicParams = false; // Any other URL is a 404

export function generateStaticParams() {
  return localeStaticParams(LOCALES, blogPostStaticParams);
}

export async function generateMetadata({ params }: Props) {
  const { locale, slug } = await localeParams(params);
  return getBlogPostPageMetadata(locale, slug);
}

export default async function BlogPostRoutePage({ params }: Props) {
  const { locale, slug } = await localeParams(params);
  return <BlogPostPage locale={locale} slug={slug} />;
}

For this kind of site, static generation has clear benefits:

  • content only changes with a deployment;
  • pages arrive as HTML that is already rendered;
  • search engines read the full content without running JavaScript;
  • there is no database to query on each visit.

App Router architecture

text
app/
├── [locale]/
│   ├── layout.tsx      # A single root layout for the three languages
│   ├── page.tsx        # Home page
│   ├── [slug]/         # Profile, hiring and freelance pages
│   ├── blog/           # Index, articles and French topic hubs
│   ├── projects/       # Case studies (also projets/ and proyectos/)
│   └── mini-projects/  # Experiments (also mini-projets/ and mini-proyectos/)
├── feeds/              # RSS, Atom and JSON feeds
├── og/                 # Social images generated at build time
├── sitemap.ts
├── robots.ts
└── globals.css

The single root layout is a deliberate choice. Next.js reloads the whole document when a navigation changes root layout, so one layout per language would have turned each language switch into a full page load.

TypeScript for type safety

TypeScript catches errors in the code, but articles are written in MDX files that it cannot check. So each article goes through a Zod schema at build time:

typescript
// lib/blog.ts (excerpt)
const frontmatterSchema = z.object({
  title: z.string().min(1),
  description: z.string().min(1),
  updatedAt: z.string().optional(),
  tags: z.array(z.string()).default([]),
  relatedSlugs: z.array(slugSchema).optional(),
  published: z.boolean().default(false),
  seoTitle: z.string().optional(),
  seoDescription: z.string().optional(),
  noindex: z.boolean().optional(),
  language: z.enum(BLOG_LANGUAGES),
  translations: z.partialRecord(z.enum(BLOG_LANGUAGES), slugSchema).default({}),
  summary: z.array(z.string().min(1)).min(2).max(6).optional(),
});

A malformed frontmatter throws an error that names the file and the field, so the build stops instead of publishing a broken page.

Styling with Tailwind CSS

I use Tailwind CSS for layout and spacing, and CSS Modules for what is too specific for utility classes, such as the route motif of the home page and the project cards.

CSS variables for theming

Colours are design tokens, redefined for dark mode:

css
:root {
  --background: 220 20% 98%;
  --foreground: 224 30% 10%;
  --primary: 0 72% 47%;
  --muted: 220 16% 95%;
}

.dark {
  --background: 224 27% 6%;
  --foreground: 210 30% 95%;
  --primary: 0 72% 47%;
  --muted: 224 20% 13%;
}

A script (npm run check:contrast) checks these tokens against WCAG AA in CI, so a colour change cannot quietly break contrast.

Performance optimizations

Image optimization

The portrait is the largest element of the home page, so it gets priority and exact sizes:

tsx
<Image
  src="/images/mouhssine-lakhili-portrait-1x1.jpg"
  alt={t["hero.photo_alt"]}
  fill
  priority
  fetchPriority="high"
  sizes="(min-width: 1280px) 352px, (min-width: 1024px) 320px, (min-width: 768px) 224px, (min-width: 640px) 320px, 288px"
  className="object-cover object-[62%_50%]"
/>

It never animates either: in this design, the name and the photo are visible right away, and the animation is only on the route motif around them.

Code splitting

Next.js splits the code by route, but all the mini-projects share a single route. Dynamic imports keep the code of one experiment off the page of another:

typescript
// components/mini-projects/experiences.tsx (excerpt)
const MINI_PROJECT_EXPERIENCES = {
  "os-404": {
    LaunchButton: dynamic(() => import("./os-404-launcher").then((module) => module.Os404BootButton)),
    Host: dynamic(() => import("./os-404-launcher").then((module) => module.Os404Host)),
  },
  // ...
};

Font optimization

next/font hosts the fonts with the site and limits layout shifts:

typescript
// "latin" covers every character used in English, French and Spanish
const sans = Inter({ subsets: ["latin"], variable: "--font-sans", display: "swap" });
const display = Syne({ subsets: ["latin"], variable: "--font-display", display: "swap" });

SEO implementation

I described the mistakes this setup still let through in the audit of this site. Here is how it is built.

Metadata from a single function

Every page calls buildMetadata, which produces the canonical URL, the hreflang alternates, Open Graph and Twitter Cards. One rule is worth showing: the brand is only added to the title when it fits, because a long title would otherwise lose its last words in search results.

typescript
// lib/seo/metadata.ts
const MAX_TITLE_LENGTH = 60;
const BRAND_SUFFIX = ` | ${SITE_NAME}`;

export function resolveTitle(title: string, absolute = false): Metadata["title"] {
  return absolute || title.length + BRAND_SUFFIX.length > MAX_TITLE_LENGTH ? { absolute: title } : title;
}

Structured data (JSON-LD)

Each page has one @graph, and its nodes reference each other through stable @ids. The WebSite entity is identical in all languages and declares the root of the domain:

typescript
// lib/seo/jsonld.ts (excerpt)
export function websiteNode(): Node {
  return {
    "@type": "WebSite",
    "@id": WEBSITE_ID,
    url: `${SITE_URL}/`,
    name: SITE_NAME,
    inLanguage: LOCALES.map((locale) => LOCALE_TO_LANGUAGE_TAG[locale]),
    publisher: { "@id": PERSON_ID },
  };
}

An article adds a BlogPosting and a breadcrumb, plus a FAQPage when it has a real FAQ section.

A sitemap generated from the content

There is no generation script to run: app/sitemap.ts reads the same data as the pages, so a new article appears in it automatically. Each URL declares its alternates in the other languages, like the HTML does:

typescript
// app/sitemap.ts (excerpt)
function localized(pathFor: (locale: Locale) => string, extras = () => ({})): Entry[] {
  const languages = Object.fromEntries(LOCALES.map((locale) => [locale, toAbsoluteUrl(pathFor(locale))]));
  languages["x-default"] = toAbsoluteUrl(pathFor("en"));

  return LOCALES.map((locale) => ({
    url: toAbsoluteUrl(pathFor(locale)),
    alternates: { languages },
    ...extras(locale),
  }));
}

Internationalization (i18n)

The site does not use an i18n library. Three pieces do the work:

  • URLs. Each language has its own URLs, including their slugs (/en/projects/opspilot, /fr/projets/opspilot), and lib/routes.ts is the only place that knows them.
  • Texts. Interface strings live in one typed dictionary per language (lib/i18n/en.ts, fr.ts, es.ts). Articles are separate MDX files, written for each language.
  • The language switch. It is a real link, so crawlers can follow it and Cmd or Ctrl-click opens a new tab. A plain click stays on the client side, keeps your place on the page when a translation exists, and fades between the two languages.
tsx
// components/language-provider.tsx (excerpt)
<a
  {...props}
  hrefLang={locale}
  lang={locale}
  onClick={(event) => {
    if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
    event.preventDefault();
    changeLanguage(locale);
  }}
/>

Deployment on Vercel

Each push runs the same checks in GitHub Actions: type check, lint, unit tests, contrast, SEO checks, build and a dependency audit. Vercel then deploys: a preview URL for a branch, production for main, and only production reports analytics.

The SEO checks (npm run check:seo) stop what is easy to forget: a title that is too long, a broken internal link, a link to a redirect, a link to a noindex article or a missing translation.

Key takeaways

  1. Start with performance in mind: it is easier to stay fast than to make a slow site fast.
  2. Validate content like code: a schema catches what TypeScript cannot see in a Markdown file.
  3. Put your SEO rules in a script: a check in CI lasts longer than a good intention.
  4. Accessibility matters: use semantic HTML, test contrast and respect reduced motion.
  5. Keep it simple: this site has no i18n library and no CMS, and nothing has required one so far.

What changed since the first version

The first version of this article listed an RSS feed among future plans. Here is what actually happened:

  • RSS, Atom and JSON feeds for each language;
  • case studies of my main projects;
  • two mini-projects you can launch in the browser: a fake desktop and a puzzle game;
  • a full SEO audit in November 2026, which found that a perfect Lighthouse score was hiding real problems.

Conclusion

Building a portfolio is more than showcasing projects. It is the one project a visitor can inspect directly: how fast it loads, how it behaves on a phone, what its source looks like.

If you are building your own, Next.js is a good option, especially if you already write React. Static pages and the metadata API cover most of what such a site needs.

Feel free to explore my GitHub, my profile page, my hiring page or my freelance page if you have questions.


Want to discuss this article or your own portfolio? Connect with me on LinkedIn or X.

Share this article

XLinkedIn

Open to work

Hiring, or planning a web project?

I'm available for a permanent role and for freelance missions (React, Next.js, Node.js, automation), in Paris or remotely. This blog shows how I scope, build and secure my work.

All articles