Building Portfolio with Next.js: Add Pages

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 π, As mentioned in the earlier post, I mistakenly read the Pages Router docs instead of the App Router. To use the App Router consistently, I have to move the files (routes) inside the pages folder into the app folder. What I Learned S...
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 π,
I executed the plan to add pages to the portfolio project. I love how convenient routing handling is in Next.js.
In version 13, Next.js introduced the new App Router that is built on React Server Component.
π Special note:
In the docs, two features are available, App Router and Pages Router. We can choose between two from the dropdown menu at the top sidebar. We must keep in mind which tab we choose as each of them is unique.
It's recommended to migrate to App Router to get the most out of React's latest features.
Next.js uses a file-system-based router where folders are used to define routes. For example, if my app folder has this structure:
app
βββ global.css
βββ layout.js
βββ page.js
βββ blog
βββ page.js
βββ post-one.md
Then the route to post one will be website.com/blog/post-one.
The breakdown of the route:
The page.js under the app folder is the route to the first slash (/) after website.com.
The page.js that lives under the blog folder is the route to blog/.
The post-one.md is the route to post-one.
Read the Routing Fundamentals section in the docs for a thorough explanation.
page.js is used to make the route publicly accessible. The URL path from a folder without page.js won't be accessible to the public.<a>) tag in HTML, <Link> also uses the href attribute/prop. The difference is that we use <Link> if we want to navigate between routes in our application, and we use <a> when we want to navigate to an external URL path.By default, there is a page.js file in the app folder. This file used to be called index.js. I use it as the homepage of the website. For now, it only shows the homepage title.
I created a pages folder in the root and added about-me.js, blog.js, and contact.js. Like the homepage, there's only a title on every page for now.
I want every page to have a link back to the homepage so I don't need to type the URL path every time.
Import the Link.
import Link from "next/link"
Applied the link to get back to the homepage.
<p>
Back to <Link href='/'>Homepage</Link>
</p>
Now as I'm writing this post, I think I messed up between the two featuresβApp Router and Pages Routerβin the docs π .
The Learn Next.js tutorial on the Next.js website uses the Pages Router. So I probably read the Pages Router docs without switching to the App Router. Because I'm using the App Router, I think I should adjust something regarding the pages for the next step. Well, I need to reread the docs π.
Read the docs and see if I should fix anything regarding the pages.
Create a navbar and a footer.
Thank you for reading! Last, you can find me on Twitter, Mastodon, and BlueSky. Let's connect! π