How to create easier handles via google sheets

Topic summary

A Google Sheets custom function for automatically generating URL-friendly handles from product titles.

Implementation:

  • Add the provided JavaScript code to Google Sheets via AppScript
  • Use the formula =handle("your product titles here") in any cell

Function capabilities:

  • Converts text to lowercase
  • Replaces spaces with hyphens (-)
  • Removes special characters (commas, asterisks, periods, parentheses)
  • Normalizes accented characters (á→a, é→e, í→i, ó→o, ú→u, ñ→n)
  • Handles both uppercase and lowercase accented letters
  • Replaces ampersands (&) and plus signs (+) with hyphens

Note: The code snippet appears partially corrupted or reversed in the latter portion, which may affect functionality. Users should verify the complete, properly formatted code before implementation.

Summarized with AI on November 15. AI used: claude-sonnet-4-5-20250929.

Hello everyone, i created a google sheet function to create faster handles, i hope this works for you.

Go to AppScript on google sheets and insert this code as a new function, then you can use =handle(“your prodcut titles here”) and thats it :wink: this functions puts everything in lower case, ads - to the blank spaces and removes special caracters aswell as accents or weirds things

function handle(texto) {
  // Comprueba si se proporcionó un valor.
  if (!texto) {
    return '';
  }

  // Reemplaza las vocales y caracteres raros con acento por guiones para las urls de shopi
  var textoSinAcentos = texto.toString().replace(/á/g, 'a')
                                        .replace(/é/g, 'e')
                                        .replace(/í/g, 'i')
                                        .replace(/ó/g, 'o')
                                        .replace(/ú/g, 'u')
                                        .replace(/Á/g, 'A')
                                        .replace(/É/g, 'E')
                                        .replace(/Í/g, 'I')
                                        .replace(/Ó/g, 'O')
                                        .replace(/Ú/g, 'U')
                                        .replace(/ñ/g, 'n')
                                        .replace(/Ñ/g, 'N')
                                        .replace(/ /g, '-')
                                        .replace(/\(/g, '-')
                                        .replace(/\)/g, '-')
                                        .replace(/&/g, '-')
                                        .replace(/\*/g, '')
                                        .replace(/,/g, '')
                                        .replace(/\./g, '')
                                        .replace(/\+/g, '-')
                                        .replace(/\//g, '-');

  var textoEnMinusculas = textoSinAcentos.toLowerCase();

  return textoEnMinusculas;
}
1 Like