title: URL dynamically generated with jquery is partially duplicated
body: <p>I'm trying to dynamically generate a list of news items in queries. The news is read from a .json file and the html code is generated accordingly.
  Since it is a bilingual site (IT-EN) I divided all the pages (except the home pages) into two sub-folders, called it and en.
  The link to the news page is generated dynamically by identifying the inserted language as the lang attribute in the  tag of the page and adding "news #" suggested by the numerical index of the in the json.
  When I go to the news page I use <code>window.location.toString (). Split ('#')</code>  to split the url and then select the one that comes after #.
  I managed to dynamically generate everything and it works 99% but the link has a duplicate language:
  instead of <code>/en/news#</code> o <code>/it/news# ottengo /it/it/news#</code>.
  I omit the extension as it is automatically inserted by .htaccess</p>
  
  <p>I tried to eliminate the variables that contain the link and the language by writing everything directly but it didn't help.</p>
  
  <pre><code>function genera_elencoNews (objDati){   
      let lingua = $('html')[0].lang.toLowerCase();
      let articolo = objDati.articoli;
          articolo = articolo.reverse();
  
      let article         = '';
      let link_img        = '';
      let link            = '';
      let foto            = '';
      let data_articolo   = '';
      let titolo          = '';
      let contenuto       = '';
  
      for (let i = 0; i &lt; Object.keys(objDati.articoli).length; i++){
          article         = $('&lt;article&gt;').attr('class', 'box excerpt');
  
  
          link_img        = $('&lt;a&gt;').attr('class', 'image left').attr('href', lingua + '/news#' + articolo[i].newsId); 
          link            = $('&lt;a&gt;').attr('href', lingua + '/news#' + articolo[i].newsId);
          foto            = $('&lt;img&gt;').attr('class', 'Miniatura').attr('src', '/img/news/'+ articolo[i].foto);
          data_articolo   = $('&lt;span&gt;').attr('class', 'date').html(articolo[i].data);
          titolo          = articolo[i].titolo;
          contenuto       = $('&lt;p&gt;').html(articolo[i].contenuto.substring (0, 200) + '...');
  
          $(article)//Genitore. tutto il resto è inserito dentro &lt;article&gt;        
              .prepend(link_img.append(foto))// Inserisce link e dentro mette la foto &lt;article&gt; --&gt; &lt;a&gt; --&gt;&lt;img&gt;
                  .append($('&lt;div&gt;') //&lt;article&gt; --&gt; &lt;div&gt;            
                      .append($('&lt;header&gt;')// &lt;article&gt; --&gt; &lt;div&gt; --&gt; &lt;header&gt;
                          .append(data_articolo)//&lt;article&gt; ---&gt; &lt;div&gt; ---&gt;&lt;header&gt; ---&gt;&lt;span&gt;DATA
                              .append($('&lt;h3&gt;')
                                  .append(link.html(titolo)))) 
                      .append(contenuto))         
              .appendTo('#ultimeNews');
      }
  }
  </code></pre>