0

So I'm dynamically filling a small set of template pages with dynamic data from a DB, with the dynamic inputs contained in the URL params.

I'm using a URL rewriter(mod_rewrite) to create static-looking URLs for these template pages, but I'd really like to have the page titles be dynamic too.

I've found out how to do this in javascript after the page has been loaded, but apparently that won't work correctly for SEO, or for links to the page.

The main example I have, is that the wiki page for genome.

http://en.wikipedia.org/wiki/genome

… is rewritten to:

http://en.wikipedia.org/w/index.php?title=genome

Yet the page title will be Genome - Wikipedia, instead of Template - Wikipedia.

How does wikipedia dynamically rename the page title? Somehow I doubt they create new static html pages for every single article, they probably use a template.

Is there any way to have a parameter be assigned to the page title?

Thanks in advance.

thouliha
  • 4,762
  • 4
  • 32
  • 46
  • You can change the title the same way you change any other part of the page. – SLaks Sep 12 '14 at 14:26
  • 1
    wiki likely does it using php. `<?php echo $_GET["title"]; ?>` or whatever templating engine they're using. – Kevin B Sep 12 '14 at 14:33
  • Hrm.. I'm using a non-php backend, and doing javascript ajax to populated everything. Would using a – thouliha Sep 12 '14 at 14:41
  • 1
    No, you'll have the same problem. To solve this while avoiding the potential seo issue you are having, this would have to be done where the HTML is being generated, on the server. – Kevin B Sep 12 '14 at 14:43
  • I think I'm screwed then. The HTML pages aren't generated, they're static templates. @KevinB – thouliha Sep 12 '14 at 14:46
  • What parses and populates the template? client-side javascript? – Kevin B Sep 12 '14 at 14:50
  • Yup, client-side javascript AJAX to a back-end. @KevinB – thouliha Sep 12 '14 at 15:39
  • This this a SPA? if it is, then the seo implications are somewhat irrelevant, since the fact that you're ajaxing in content has the same issue. – Kevin B Sep 12 '14 at 15:44

1 Answers1

0

You can always write javascript to rename the page title from the argument; document.title = "This is the new page title.";

How to dynamically change a web page's title?

Community
  • 1
  • 1
Dmitry Sadakov
  • 2,080
  • 2
  • 19
  • 31
  • I did find this answer before, but it apparently doesn't work for SEO or linking: https://stackoverflow.com/a/413455/1655478 – thouliha Sep 12 '14 at 14:31