Guide to concealing a language path within a url using an exception

I currently have a website with various language versions, with English set as the default.

Is there a way to conceal the /en/ path from the URL? (making an exception for just en)

I want to maintain the other languages unchanged.

www.website.com/en/ (want to hide en for default homepage)

www.website.com/fr/ (other languages should remain the same)

Thank you!

This pertains to a vue.js application.

module.exports = [].concat.apply([], langs.map(lang => pages.map(page => `/${lang}/${page}`)))

Answer №1

One simple solution is to add a check for lang === 'en' inside your map function.

module.exports = [].concat.apply([],
    langs.map(lang =>
        pages.map(page => lang === 'en' ? `/${page}` : `/${lang}/${page}`)))

Just keep in mind the advice given in the comments, especially if your URL parameters determine the language or if your URL structure follows a different pattern like '/something/otherthing'.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to find the most commonly used category for a product in a MongoDB collection?

I've been diving into MongoDB and encountered a challenge with my current task. I'm trying to figure out how to determine the most frequently used category in a collection. According to this JSON, the most used category is CIES. My goal is to dis ...

Adjust the options in one drop-down menu based on the selection made in another drop-down menu

One of the key features of my basic form involves users selecting start and end times to record, along with choosing an appropriate location. I am looking to enhance the form so that if a user selects MARK 104 or MARK 125 as the location, the drop-down opt ...

I am experiencing a 404 error when attempting to import a local JS file in Angular

After creating a new project with "ng new xxx", all you need to do is add one line of code in index.html: <!doctype html> <html lang="en> <head> <meta charset="utf-8> <title>Bbb</title> <base href="/&g ...

Converting MongoDB Queries to MySQL in Node: A Step-by-Step Guide

I am currently facing a challenge where I need to migrate my app's database from mongoDB to mysql. The application was initially developed using node.js, but I encountered an issue with the "Create table" query while attempting the conversion process. ...

Text below a stationary header

I need some help with my code using material-ui-next beta.30. The issue I am facing is that the content within mui.Paper is appearing behind the AppBar instead of below it. Here's my current setup: import * as React from 'react'; import * a ...

Create an array in JavaScript that represents a normal distribution based on the provided minimum, maximum, mean, and sample size

Consider the following scenario: min = 1 max = 5 Ave = 3 size = 5 At this stage, we have [1,?,?,?,5] How can I determine the missing numbers? (It's simple -> [1,2,3,4,5] - but how do I create a JavaScript function to return this array) ...

The search for Javascript is futile when utilizing .Net RijndaelManaged

I have implemented an encryption/decryption process in my C# WCF using the following code: public static string EncryptString(string InputText, string Password) { RijndaelManaged RijndaelCipher = new RijndaelManaged(); RijndaelCiph ...

PHP validation for email after Ajax form submission

Currently, I am in the process of creating an HTML contact form. To validate the form upon clicking the submit button, I have integrated the JavaScript code provided below: function leftValue(e, t, n) { $(this).text(t.parent()[0].style.left) } $(document) ...

Expand the div width to the specified measurement horizontally

Is there a way to horizontally collapse a div (container) to a specific width that I can adjust, effectively hiding its content? The collapse effect should move towards the left. <div id="container"> <button type="button" id="myButton"> ...

What is causing the delay() function to malfunction?

Check out this example: $('#click').click(function() { $('#delay').delay(2000).css('background-color', '#c30000'); }); Can you explain why the delay() function does not delay the execution of the css() function i ...

Setting up redux with Next.js: a step-by-step guide

After setting up redux in this manner, everything is functioning properly. The _app.js file has been reorganized as follows : import App from 'next/app'; import { Provider } from 'react-redux'; import withRedux from 'next-redux-wr ...

Unpredictable delay experienced when making a GET request using Axios

I have been facing frequent build failures on my multiple websites built with static site generators like Gridsome and Vue. These sites fetch data from the WP REST API using Axios. Recently, I've noticed that my builds fail often due to random timeou ...

I'm having trouble with AngularJS routes not functioning properly when accessed directly. I am using html5 mode in conjunction with

When accessing URLs directly in my Angular app either through the address bar or from external links, all routes default back to the home page. However, when navigating within the app, routes work as expected. I have come across similar issues on Stack Ov ...

The "Read more" feature is not functional on mobile devices

I am encountering issues with my Wordpress blog on mobile screens. The "read more" button is not functioning, and the screen size does not fit properly on mobile devices. Visit abood250.com for more information. CSS Styling: /* =Global ----------------- ...

Display data as a JSON object using Highcharts

Looking to populate a highchart in Jade using JSON data sent from Node.js. Currently, I have successfully added static data as shown in the code snippet below: var series = [ { name: 'Tokyo', data: [7.0] } ]; Now, I am attempti ...

What are the steps to styling a component with CSS Emotion?

I am facing an issue with using a theme with TypeScript in this component const buttonDisabled = css` color: ${({ theme }) => theme.color}; `; Is there a way to correctly type this component? Error: No overload matches this call. Overload 1 of 2, & ...

pm2 doesn't play well with node dotenv

In my current project, I'm faced with an interesting issue. When running the application locally without pm2, all the environment variables in the .env file are properly recognized using dotenv. However, when deploying the app on a server and using p ...

Validation of forms - Must include one particular word from a given set

I am in the process of utilizing Javascript to validate an input field with the specific formatting requirements outlined below: "WORD1,WORD2" The input must contain a comma separating two words, without any spaces. The first word (WORD1) can be any word ...

Having trouble with parsing JSON data using jQuery?

I am currently working on retrieving a result set using postcodes with jQuery autocomplete. However, the code I have implemented seems to be displaying an empty set of rows. <html lang="en"> <head> <meta charset="utf-8> <title>Ausp ...

Personalized Navigation Bar Toggle (transitioning from dropdown to sliding from the left)

On larger screens, I would like the navigation/navbar to be positioned at the top. However, on mobile view or when collapsed, I want the toggle button to reveal the navigation menu by sliding from the left side, similar to this example: (source by David B ...