How to Rename a Menu and Change URL Structure in Astro Without Breaking the Site? #336
-
I am currently learning Astro, and I need help with renaming a menu and modifying its URL structure without causing my website to crash. What I’m Trying to Do Problems I’m Facing What I’ve Tried Questions I Need Help With Since I’m still new to Astro, I would appreciate any detailed guidance or best practices for renaming menu items and modifying URLs without breaking the entire site. Thank you in advance for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @Daremonic! I'd recommend starting with Astro's official tutorial to get hands-on experience: As for the template:
// An array of links for the navigation bar
const navBarLinks = [
{ name: "Home", url: "/" },
{ name: "Solutions", url: "/solutions" },
]; If using i18n, update both language versions, e.g. const navBarLinks = [
{ name: "Accueil", url: "/fr" },
{ name: "Solutions", url: "/fr/solutions" },
];
// Importing necessary components
import MainLayout from "@/layouts/MainLayout.astro";
import PrimaryCTA from "@components/ui/buttons/PrimaryCTA.astro";
import CardSmall from "@components/ui/cards/CardSmall.astro";
import CardWide from "@components/ui/cards/CardWide.astro";
import FeaturesStatsAlt from "@components/sections/features/FeaturesStatsAlt.astro";
import TestimonialsSectionAlt from "@components/sections/testimonials/TestimonialsSectionAlt.astro"; Make a note of the
<a
href={productLocale && productLocale !== "en"
? `/${productLocale}/solutions/${product.id.replace(/^fr\//, "")}/`
: `/solutions/${product.id.replace(/^en\//, "")}/`}
> Then rename the |
Beta Was this translation helpful? Give feedback.
Hey @Daremonic!
I'd recommend starting with Astro's official tutorial to get hands-on experience:
https://docs.astro.build/en/tutorial/0-introduction/
As for the template:
navigation.ts
file in yourutils
folder, update the links:If using i18n, update both language versions, e.g.
utils/fr/navigation.ts
:pages
directory, rename theproducts
folder tosolutions
.solutions
folder, openindex.astro
and ch…