<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Jordan Thirkle's Blog]]></title><description><![CDATA[Aspiring Web Developer.

Documenting my learning journey @Jordan_Thirkle.

https://x.com/jordan_thirkle]]></description><link>https://jordanthirkle.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 09:30:15 GMT</lastBuildDate><atom:link href="https://jordanthirkle.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Learned how to create a Global Header and Footer with layout.tsx in Next.js 13 App Router]]></title><description><![CDATA[Discover how to create global header and footer components on your Next.js website using through Layout.tsx using Next.js v13's app router.]]></description><link>https://jordanthirkle.hashnode.dev/learned-how-to-create-a-global-header-and-footer-with-layouttsx-in-nextjs-13-app-router</link><guid isPermaLink="true">https://jordanthirkle.hashnode.dev/learned-how-to-create-a-global-header-and-footer-with-layouttsx-in-nextjs-13-app-router</guid><category><![CDATA[Next.js]]></category><category><![CDATA[Tailwind CSS]]></category><category><![CDATA[Creating Global Header & Footer in Next.js 13 App Router with Layout.tsx]]></category><dc:creator><![CDATA[Jordan Thirkle]]></dc:creator><pubDate>Mon, 21 Aug 2023 19:47:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1692647480998/b0a05975-9bf5-4fe7-ac8c-06a601a99d86.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Before learning Next.js</strong>, my journey in web development was centered around creating websites using <em>HTML</em> and <em>CSS</em>.</p>
<p><em>As a beginner</em>, I often found myself <strong>duplicating header and footer code</strong> across multiple pages.</p>
<p>This repetition not only <strong>added complexity to my projects</strong> but also made <em>maintaining consistency</em> a cumbersome task.</p>
<p>It was clear that <em>a more efficient and scalable approach</em> was needed to <em>streamline the process</em>.</p>
<p>This is where <strong>Next.js and its powerful features</strong> came into play.</p>
<p><strong>Revolutionizing the way I can structure and manage my web applications.</strong></p>
<p><em>In this guide</em>, I'll walk you through how I overcame this challenge by creating a <strong>global header and footer</strong> using the <code>layout.tsx</code> file, leveraging Next.js 13's app router.</p>
<h2 id="heading-global-header">Global Header</h2>
<p><strong>A global header is like the welcoming mat of your website.</strong></p>
<p>It not only reflects my <em>brand identity</em> but also offers a way for users to navigate through your content <em>effortlessly</em>.</p>
<p>Here's how I added a global header to my Next.js project:</p>
<p>First, I created a <code>header.tsx</code> component in my <code>app</code> directory.</p>
<p>This component houses the <em>HTML structure and content</em> of my header, including navigation links and social media icons.</p>
<p>I used the <code>&lt;Link&gt;</code> component from Next.js to ensure <em>smooth navigation between pages</em>.</p>
<p>Here's my header code:</p>
<p><code>header.tsx file:</code></p>
<pre><code class="lang-plaintext">// app/header.tsx

// Import necessary modules
import Link from 'next/link';
import { FaTwitter, FaGithub, FaLinkedin } from 'react-icons/fa';

// Define the Header component
export default function Header() {
  return (
    &lt;header className="bg-gray-900 text-white py-4 sticky top-0 z-50"&gt;
      {/* Header container */}
      &lt;div className="container mx-auto px-4 flex justify-between items-center"&gt;
        {/* Website title */}
        &lt;h1 className="text-xl font-semibold"&gt;Jordan Thirkle&lt;/h1&gt;
        {/* Navigation menu */}
        &lt;nav className="hidden md:block"&gt;
          &lt;ul className="flex gap-x-6"&gt;
            {/* Navigation links */}
            &lt;li&gt;
              &lt;Link href="/" className="hover:text-gray-300"&gt;
                Home
              &lt;/Link&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;Link href="/about" className="hover:text-gray-300"&gt;
                About
              &lt;/Link&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;Link href="/portfolio" className="hover:text-gray-300"&gt;
                Portfolio
              &lt;/Link&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;Link href="/blog" className="hover:text-gray-300"&gt;
                Blog
              &lt;/Link&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;Link href="/contact" className="hover:text-gray-300"&gt;
                Contact
              &lt;/Link&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;/nav&gt;
        {/* Social media icons */}
        &lt;div className="hidden md:block"&gt;
          &lt;SocialIcons /&gt;
        &lt;/div&gt;
        {/* Add Mobile Navigation Toggle Here */}
      &lt;/div&gt;
    &lt;/header&gt;
  );
}

// Define the SocialIcons component
function SocialIcons() {
  return (
    &lt;div className="flex gap-x-4"&gt;
      {/* Twitter icon */}
      &lt;a
        href="https://twitter.com/Jordan_Thirkle"
        target="_blank"
        rel="noopener noreferrer"
      &gt;
        &lt;FaTwitter className="text-white hover:text-gray-300" /&gt;
      &lt;/a&gt;
      {/* GitHub icon */}
      &lt;a
        href="https://github.com/jordan-thirkle"
        target="_blank"
        rel="noopener noreferrer"
      &gt;
        &lt;FaGithub className="text-white hover:text-gray-300" /&gt;
      &lt;/a&gt;
      {/* Add more social media icons as needed */}
    &lt;/div&gt;
  );
}
</code></pre>
<h2 id="heading-global-footer">Global Footer</h2>
<p>Completing the user journey, a <strong>global footer</strong> serves as a reminder of my brand and provides a convenient way for visitors to connect with me.</p>
<p>Here's how I added a global footer:</p>
<p>I created a <code>footer.tsx</code> file for the footer's content, including my name and copyright year.</p>
<p>Additionally, I included a link to my Twitter profile for easy connection.</p>
<p>This is my footer code:</p>
<p><code>app/footer.tsx</code></p>
<pre><code class="lang-plaintext">// app/footer.tsx

// Import necessary modules
import Link from 'next/link';
import { FaGithub, FaTwitter } from 'react-icons/fa';

// Define the Footer component
export default function Footer() {
  return (
    &lt;footer&gt;
      {/* First section of the footer */}
      &lt;div&gt;
        {/* Display your name and the current year */}
        &lt;p&gt;Your Name &amp;copy; {new Date().getFullYear()}&lt;/p&gt;
      &lt;/div&gt;
      {/* Second section of the footer */}
      &lt;div&gt;
        {/* Provide a link to your Twitter profile */}
        &lt;a href="https://twitter.com/your-username"&gt;
          Connect on Twitter
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/footer&gt;
  );
}
</code></pre>
<h2 id="heading-layouttsx-global-layout">layout.tsx: Global Layout</h2>
<p>With <strong>Next.js 13's app router</strong>, I took it a step further by centralizing these global components using the <code>layout.tsx</code> file.</p>
<p>This file acts as the backbone of my project, ensuring that the header and footer remain consistent across all pages.</p>
<p>I wrapped my page components with this layout component for a seamless experience.</p>
<p>Here's how I did it:</p>
<p><code>app/layout.tsx</code> file:</p>
<pre><code class="lang-plaintext">// app/layout.tsx

// Import global styles
import './globals.css';

// Import necessary types from Next.js
import type { Metadata } from 'next';

// Import the Inter font from Google Fonts
import { Inter } from 'next/font/google';

// Import the Header and Footer components
import Header from './header';
import Footer from './footer';

// Initialize the Inter font with a Latin subset
const inter = Inter({ subsets: ['latin'] });

// Define metadata for the website
export const metadata: Metadata = {
  title: "Jordan Thirkle's Personal Website",
  description: "An Aspiring Web Developer.",
};

// Define the RootLayout component, which will be used to wrap pages
export default function RootLayout({
  children, // React children components to be wrapped
}: {
  children: React.ReactNode;
}) {
  return (
    // Start of the HTML document
    &lt;html lang="en"&gt;
      {/* Set the body class to apply the Inter font */}
      &lt;body className={inter.className}&gt;
        {/* Include the Header component */}
        &lt;Header /&gt;

        {/* Render the child components within the layout */}
        {children}

        {/* Include the Footer component */}
        &lt;Footer /&gt;
      &lt;/body&gt;
    &lt;/html&gt;
    // End of the HTML document
  );
}
</code></pre>
<p>By integrating this code, it creates a <strong>RootLayout</strong> component that serves as a wrapper for all pages in your Next.js application.</p>
<p>It imports global styles, font, metadata, and the <strong>Header</strong> and <strong>Footer</strong> components.</p>
<p>The <strong>RootLayout</strong> component ensures a consistent layout structure across different pages, making it easier to manage and maintain your website.</p>
<p>Implementing this setup into my Next.js project, I've achieved a cohesive design and an improved user experience.</p>
<p><em>Consistency, navigation, and brand identity are now seamlessly integrated into my website, thanks to these global headers and footers.</em></p>
<h1 id="heading-thank-you-for-reading-my-blog-post">Thank you for reading my blog post!</h1>
<p>If you enjoyed learning about creating a global header and footer in Next.js, make sure to follow my web development journey on <a target="_blank" href="https://x.com/jordan_thirkle"><strong>X (Twitter)</strong></a>, where I share my experiences and insights.</p>
<p>For more about me, my projects, and my coding adventures, be sure to <a target="_blank" href="https://www.jordanthirkle.com">visit my personal website</a>.</p>
<p>Whether you're looking to collaborate, learn, or simply say hello, I'm always thrilled to connect with fellow developers and enthusiasts.</p>
<p>Stay tuned for more of my learning journey and coding tips that I've learned along the way!</p>
<p><a target="_blank" href="https://jordanthirkle.hashnode.dev/">Visit My Blog</a> | <a target="_blank" href="https://www.jordanthirkle.com">Visit My Website</a> | <a target="_blank" href="https://twitter.com/jordan_thirkle">Follow me on X (Twitter)</a> | <a target="_blank" href="https://github.com/jordan-thirkle">GitHub</a></p>
]]></content:encoded></item></channel></rss>