Building Portfolio with Next.js: Add Navbar, Footer, and Metadata

Ayu is a tech blogger, open source contributor & maintainer, and tech community enthusiast based in the Netherlands. She loves photography and iced coffee!
Search for a command to run...

Ayu is a tech blogger, open source contributor & maintainer, and tech community enthusiast based in the Netherlands. She loves photography and iced coffee!
No comments yet. Be the first to comment.
A series of my notes as I learn NextJS and Tailwind and build my portfolio website publicly.
Hello Friends π, It has been so many moons since my last blog post and since I did coding. Life came in between, and I had to focus on that first for my mental health's sake. It's still lingering, but I'm in a much better state now π. So I'm slowly...
Hi friends π, I've been writing tech blog posts for a few years now. If you don't know me yet, English is my second language. My mother tongue is Indonesian, and I'm also surrounded by Dutch every da

I frequently receive messages from enthusiastic contributors who have completed 2 or 3 high-quality pull requests (PRs) in just 1 month. Theyβre proactive, their work is top-tier, and theyβve handled

A few months ago, I shared a story about building an automated open source portfolio using just my smartphone and an AI assistant while on vacation. My main goal was to stop the "spreadsheet struggle"

Recently, I read Bekah Hawrot Weigelβs blog post, "When 'Local' Went Global: The Pandemic Era of International Communities." As someone active in many online communities, I found it a bit sad, but I agree with her points and think they apply to open ...

Hacktoberfest is almost over. How has your contribution journey been so far? Are you confident about contributing to open source projects, or are you still struggling to find your way? If you're new to open source and still feel overwhelmed, that's c...

Hello Friends π,
So, I've added a navbar, footer, and metadata to my project.

Root layout applies to all routes and is required.
To make Navbar and Footer show on every page, we need to import and apply them in the root layout that we can find in the layout.js in the app folder.
Say we want a completely different UI or experience, e.g., for public view pages and dashboard. We can create multiple root layouts based on our needs.
Metadata (or metainformation) is "data that provides information about other data" β Wikipedia
Next.js has Metadata API that can define our application metadata and automatically generate the relevant <head> elements for our pages.
When a route doesn't define metadata, Next.js will always add two meta tags: meta charset and meta viewport.
I created a components folder in the app folder.
I created Navbar.js and Footer.js files in the components folder.
app
βββ (websitePages)
βββ components
β βββ Footer.js
β βββ Navbar.js
βββ globals.css
βββ layout.css
βββ page.js
Then I imported and applied the Navbar and the Footer in the RootLayout:
import "./globals.css"
import { Inter } from "next/font/google"
import Navbar from "./components/Navbar"
import Footer from "./components/Footer"
const inter = Inter({ subsets: ["latin"] })
export const metadata = {
title: "Ayu Adiati",
description: "Ayu Adiati's portfolio",
}
export default function RootLayout({ children }) {
return (
<html lang='en'>
<body className={inter.className}>
<Navbar />
{children}
<Footer />
</body>
</html>
)
}
I added static metadata to all page.js as in the example below:
// metadata Blog page
export const metadata = {
title: "Ayu Adiati | Blog",
description: "Ayu Adiati's blog posts",
}
export default function Blog() {}
Reading through the docs, I learned about the title.template. I probably will use this in the future.
I know metadata helps improve SEO, but I need more knowledge. So I will do more research about metadata in general.
Basic styling.
I want to have a decent style for the navbar and footer for now.
Potential Blockers
I'm crossing my fingers that I have time to continue the project during vacation π€π.

πΌοΈ Credit cover image: unDraw
Thank you for reading! Last, you can find me on Twitter, Mastodon, and BlueSky. Let's connect! π