Ajax Loaded meta Tags

2019-07-16 04:32发布

问题:

Im quite new to the wonders of ajax. I've been playing around with stuff etc.

To elaborate, i have a simple 5 page website where every page is the same except for the content. Pretty generic scenario. So what i've done, is just added the content for each page using ajax. Meaning that in my website folder, i have ONE .php file. (kind of like a master page.) and all the content changes are just in smaller .html files that are loaded.

For Seo, Each page needs meta tags etc...

But if i have ONE page where just the content changes, obviously the meta tags for every page will be the same. Because the meta tags arent changing when the content is loaded.

So my question is... If I also have corresponding meta tag files and load them into the head at the same time as loading the content. The meta tags will then Change, Which is what im after.

BUT!!! because its all in one page and the meta tags will be loaded from separate file, will search engines still be able to... kind of work. Like, will google know that the website is one page but the meta tags are different?

I cant think of a better way to explain this. But any advice would be useful:) and if not... Will i have to revert my site back to the boring method of one file per page etc.

Cheers:)

x

回答1:

As the meta tags are part of the dom you would be able to change the values. If you are trying to change them for SEO/Search engines I don't think it will make any difference as the spider (as far as I know) doesn't execute javascript.

You are best off making sure the site functions as you wish when javascript is disabled. Refered to as 'Unobtrusive JavaScript' or 'Graceful Degredation'.



标签: php ajax seo