智能阿贾克斯深,使得元数据在加载HTML链接的搜索引擎,而不是DOM而不是、加载、搜索引擎、链接

2023-09-10 21:57:45 作者:再见陌路

我在寻找的深层链接一个很好的方式与不同的 meta标签即可。目前,我有一个巨大的主HTML网站,并显示通过JavaScript和DOM操作的子页面。

I'm searching for a good way of deep linking together with different meta tags. Currently I have a huge main HTML site and showing the subpages via JavaScript and DOM manipulations.

让我们以我的最新项目为例( 谷歌搜索 )。在那里,你可以看到,元标签(让我们来只是为了简化的描述)都是一样的。但是在DOM我改变了它,你可以在网站上看到的。但我知道,搜索引擎只取HTML code和有J​​S大多是残疾人。在此行中的JavaScript code,我曾经更改标题,描述和关键字。

Let's take my latest project as example (Google Search). There you can see that the meta tags (let's take just the description for simplification) are always the same. But in the DOM I changed it as you can see on the site. But I know Search Engine just take the HTML code and having JS mostly disabled. Here the lines in the JavaScript code that I used to change title, description and keywords.

    $('meta[name=keywords]').attr('content', 'ages,third');
    $('meta[name=description]').attr('content', 'The Third age is where The Hobbit and Lord of the Rings take part.');
    document.title = "Third Age - Arda Maps"; 

你可以从谷歌搜索看到,在标题适当地改变,即使寿它是通过JavaScript完成。

As you can see from the Google search, the title is properly changed, even tho it is done via JavaScript.

所以,问题是,如果有一种方法也更改其他元代码就像在一个适当的方式通过JavaScript的说明?

So the question is, if there is a way to also change other meta tags like the description via JavaScript in a proper way?

注1 的:我不想用PHP。我知道PHP将使它的方式通过模板更容易。

Note #1: I don't want to use PHP. I know PHP would make it way easier via templating.

注2 的:我也知道我可以只加载通过Ajax的不同的页面。但后来我不得不镜像它们。正如你所看到的主要HTML是非常大的。镜像会以这种方式被禁忌的生产力。难道不是吗?

Note #2: I also know I could just load the different pages via Ajax. But then I would have to mirror them. And as you can see the main html is very big. Mirroring would in this way be contra-productive. Isn't it?

推荐答案

有没有办法轻松地编辑在一个单页的Web应用程序中的meta标签作为不同的页面。唯一的办法是通过PHP或Node.js的,以服务器端更改。

There is no way to edit the meta tags on a Single-Page web application easily for different pages. The only way is via PHP or Node.js to change it on server-side.

Chaning它在客户端它只会改变DOM什么是好的用户,因为他能看到的变化。但是,搜索引擎会忽略这一点。还与都柏林核心是行不通的。即使寿它是专为眼前这个。

Chaning it on client-side it will just change the DOM what is good for the user as he can see the changes. But search engine will ignore that. Also with the Dublin Core it will not work. Even tho it is designed for just this.

所以,目前这是不可能的。

So currently this is not possible.