Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 37 ยท Projects and Practice

Project: A Portfolio Site

Build and ship a portfolio site step by step: static pages, a contact form, redirects and headers, a custom domain, preview reviews and a pre-launch checklist for Vercel or Netlify.

In this project you plan, configure and launch a small portfolio site that uses most of what the earlier chapters taught: a repository connected to the platform, preview deployments, a custom domain, redirects, security headers and a contact form. The steps work on Vercel or Netlify; differences are called out.

The platforms cannot run here, so this is a guided plan with read-only configuration and JavaScript stand-ins that check your work, such as a link checker and a launch checklist. Perform the real steps in your own account.

What you will build

A site with four pages: Home, Projects, About and Contact. It is plain HTML and CSS (or any static generator such as Astro or Eleventy; the platform steps are the same). Targets:

  • Every push to a branch gets a preview URL; main is production.
  • www.example.com redirects to example.com (or the other way round).
  • Old URL /work redirects permanently to /projects.
  • Security headers and long caching for assets.
  • A contact form that stores submissions.

Step 1: structure and repository

TEXT
portfolio/
  index.html
  projects.html
  about.html
  contact.html
  404.html
  assets/
    style.css
    app.js
  netlify.toml        (or vercel.json)

Initialize Git, push to GitHub, GitLab or Bitbucket. A 404.html in the root is served automatically for unknown paths on both platforms.

Step 2: connect and deploy

Import the repository from the dashboard (Vercel: Add New Project; Netlify: Add new site, Import an existing project). For a plain static site: framework preset "Other", no build command, publish directory . (or public). For a generator, accept the detected build command and output folder. See Build Settings and Environments for how these map to settings. Deploy, then open the generated URL.

Step 3: configuration files

Netlify, netlify.toml:

TOML
[build]
  publish = "."

[[redirects]]
  from = "/work"
  to = "/projects"
  status = 301

[[headers]]
  for = "/*"
  [headers.values]
    X-Content-Type-Options = "nosniff"
    Referrer-Policy = "strict-origin-when-cross-origin"

[[headers]]
  for = "/assets/*"
  [headers.values]
    Cache-Control = "public, max-age=31536000, immutable"

Vercel, vercel.json equivalent:

JSON
{
  "cleanUrls": true,
  "redirects": [{ "source": "/work", "destination": "/projects", "permanent": true }],
  "headers": [
    { "source": "/(.*)", "headers": [
      { "key": "X-Content-Type-Options", "value": "nosniff" },
      { "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" } ] },
    { "source": "/assets/(.*)", "headers": [
      { "key": "Cache-Control", "value": "public, max-age=31536000, immutable" } ] }
  ]
}

One caution: only mark /assets/* immutable if file names are fingerprinted or you never change them in place; otherwise use a short cache. More in Caching and the CDN and Response Headers and Security.

Step 4: the contact form

On Netlify, add data-netlify="true" and a honeypot to the form in contact.html (Forms and Submissions). On Vercel, add a function api/contact.js that validates and forwards the message to an email API using a key stored as an environment variable.

Step 5: custom domain and HTTPS

Add the domain in project settings, create the records the platform shows (apex A, www CNAME), choose the canonical host and wait for the certificate (Custom Domains and DNS, HTTPS and Certificates).

Portfolio launch plan

Repo Pages, assets, config.
Connect Import and deploy.
Harden Redirects, headers, caching.
Domain DNS, HTTPS, canonical host.

Then review a preview before merging.

1 / 2

Check the site before you ship

A link checker catches the most common launch bug: a link to a page that does not exist. This stand-in takes a map of pages and their links, plus redirect rules, and reports broken links and redirect-based links worth fixing.

JS Link checker stand-in

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Pre-launch checklist as code

Checklists are easier to trust when they are data. This stand-in computes what remains from a list of boolean answers.

JS Launch checklist stand-in

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Step 6: review and launch

  1. Make changes on a branch and open a pull request; open the preview on your phone and laptop.
  2. Run Lighthouse against the preview (Images and Web Vitals).
  3. Merge; production deploys. If anything looks wrong, roll back (Rollbacks and Promotions).
  4. Submit your sitemap to search engines and test the form from the live site.

Extensions to try

  • Add an RSS feed or a small blog with Markdown files.
  • Add Web Analytics or Speed Insights.
  • Protect a /drafts preview with a password.
  • Replace the static form with a function that sends you an email.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which setting is right for a plain HTML site with no build step?

    Static files can be published as they are. The platform only needs to know where they are.
  2. 2. Why link directly to /projects instead of the old /work URL?

    Keep the redirect for old external links, but update your own links to the final URL.
  3. 3. What should you do after a successful preview review?

    The merge to the production branch triggers the production deployment.
  4. 4. Where do secrets for an email API belong?

    Anything in client-side files is visible to every visitor.

Summary

  • A portfolio exercises the whole workflow: repo, preview, config, domain, form, launch.
  • Config files hold redirects, headers and caching rules in the repository.
  • Check links, headers and forms before launch with checklists and tools.
  • Review on a preview, merge to launch, and know where the rollback button is.

Next: Project: An API and Database App