Welcome to WebmasterWorld Guest from 23.22.220.37

Forum Moderators: open

Message Too Old, No Replies

Dynamic meta tag depending on URL?

     
12:07 pm on Jul 18, 2012 (gmt 0)

New User

joined:June 6, 2012
posts: 12
votes: 0


Is it possible to have dynamic meta tag depending on URL?

Ex:

If i have www.example.com

<meta name="example" content="example">.

If it is home.example.com

<meta name="example" content="home example">

both URL redirects to same html page.

Please help
1:38 pm on July 18, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Perfectly possible. On a small site store the data in an array. On a big site use a database.

However, I have to ask 'where does redirecting come into things?' You're either serving a page or sending a redirect.
12:25 am on July 20, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 31, 2005
posts:1108
votes: 0


I suspect he either means a rewrite or solves to the same page.

As g1smd says it is possibly, but will require some sort of server side scripting language. What scripting language is available on the web server.
6:44 am on July 20, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12693
votes: 244


Ouch. If you're rewriting more than one URL to show the same content, you've got bigger problems than how to word the <meta> tag.

But yes, I think it can be done in about four lines of javascript, since that's where we are.
6:49 am on July 20, 2012 (gmt 0)

New User

joined:June 6, 2012
posts: 12
votes: 0


I have done using the below javascript

window.getSelection ? yourTag.name= ‘tagname' : yourTag.Name= ‘tagname '
yourTag.content='example.com';
document.getElementsByTagName('head')[0].appendChild(yourTag);
1:18 pm on July 20, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


That sounds like a very bad idea.
9:52 pm on July 20, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12693
votes: 244


Do you mean the javascript itself or the rewrite?
1:18 pm on July 23, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts: 4965
votes: 10


JavaScript is not the place to be doing this. What's the point of rewriting meta data about the document after you've already started serving the document? For one thing, those without JavaScript will end up getting different meta data (think about search engines). But even more importantly, if you've got home.example.com serving the same content (or nearly the same, if you take meta data into account), as example.com, then (as lucy24 pointed out) you're going to dilute the value of your content in the eyes of search engines.
12:53 am on July 24, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 31, 2005
posts:1108
votes: 0


Which is why my original question to him was "What scripting language is available on the web server."
Client site scripting is not a good solution as Fotiman's pointing out.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members