diff --git a/src/components/LanguageButton.vue b/src/components/LanguageButton.vue
index b2609ee4f1599ef184dc651ffd951200f24f055d..50b493accf1ef427b55b766790c508fccd8c3912 100644
--- a/src/components/LanguageButton.vue
+++ b/src/components/LanguageButton.vue
@@ -27,11 +27,14 @@ function handleLanguageChange(event) {
 
 function switchLanguage(lang) {
   if (locale.value !== lang) {
-    locale.value = lang; // Update the locale
+    locale.value = lang;
 
-    // Update the URL with the new language
+    // Remove any existing language prefix from the current path
+    const currentPath = route.path.replace(/^\/(en|es)/, '');
+
+    // Construct the new path with the selected language
     router.push({
-      path: `/${lang}${route.path.substring(3) || ''}` // Preserve the existing path, only change the language
+      path: `/${lang}${currentPath || '/'}`
     });
   }
 }