如何从搜索引擎隐藏HTML文件中的内容?

时间:2020-12-07 21:14:26

Say that I write an article or document about a certain topic, but the content is meant for readers with certain prior knowledge about the topic. To help people who don't have the "required" background information, I would like to add a note to the top of the page with an explanation and possibly a link to some reference material.

假设我写了一篇关于某个主题的文章或文档,但该内容适用于具有该主题的某些先验知识的读者。为了帮助那些没有“必需”背景信息的人,我想在页面顶部添加一个注释,其中包含一些解释,可能还有一些参考资料的链接。

Here's an example:

这是一个例子:

Using The Best Product in the World to Create World Peace

利用世界上最好的产品创造世界和平

Note: This article assumes you are already familiar with The Best Product in the World. To learn more about The Best Product in the World, please see the official web site.

注意:本文假设您已熟悉世界上最好的产品。要了解有关世界上最佳产品的更多信息,请访问官方网站。

The Best Product in the World ...

世界上最好的产品......

Now, I don't want the note to show up in Google search engine results, only the title and the content that follows the note. Is there any way I can achieve this?

现在,我不希望该注释显示在Google搜索引擎结果中,只显示该注释后面的标题和内容。有什么办法可以实现吗?

Also, is it possible to do this without direct control over the entire HTML file and/or HTTP response, i.e. on blog hosted by a third party, like Wordpress.com?

此外,是否可以在不直接控制整个HTML文件和/或HTTP响应的情况下执行此操作,即在第三方(如Wordpress.com)托管的博客上执行此操作?

Update

Unfortunately, both the JavaScript solution and the HTML meta tag approach does not work on hosted Wordpress.com blogs, since they don't allow JavaScript in posts and they don't provide access to edit the HTML meta tags directly.

不幸的是,JavaScript解决方案和HTML元标记方法都不适用于托管的Wordpress.com博客,因为它们不允许在帖子中使用JavaScript,也不提供直接编辑HTML元标记的权限。

8 个解决方案

#1


4  

You can build that portion of the content dynamically using Javascript.

您可以使用Javascript动态构建该部分内容。

For example:

<html>
<body>
  <div id="dynContent">
  </div>
   Rest of the content here.
</body>
<script language='javascript' type='text/javascript'>
  var dyn = document.getElementById('dynContent');
  dyn.innerHTML = "Put the dynamic content here";
</script>
</html>

If you're really stuck, you can just go old school and reference an image that has your text as part of it. It's not particularly "accessibility-friendly" though.

如果你真的被卡住了,你可以去老学校并引用一个包含你的文字作为其中一部分的图像。尽管如此,它并不是特别“可访问性”。

#2


2  

Javascript. If you add your content to the site using javascript, it won't be picked up by the search engines. It's even appropriate, because you're enhancing the site, not providing additional content. Any other method of performing this will stick the content into the page. Even if you hide it using styling, it will still be in the text. Depending on your page structure, that might not be possible anyway.

的JavaScript。如果您使用javascript将内容添加到网站,搜索引擎将不会选择它。这甚至是合适的,因为您正在增强网站,而不是提供额外的内容。执行此操作的任何其他方法都会将内容粘贴到页面中。即使你使用样式隐藏它,它仍然会在文本中。根据您的页面结构,无论如何都可能无法实现。

#3


2  

If you can use an iframe, then place the content on a static html page and use the meta tag in it's head to tell the search engines to ignore it. Since it's a seperate page, google etc.. should ignore it.

如果您可以使用iframe,那么将内容放在静态html页面上并使用其中的元标记告诉搜索引擎忽略它。由于它是一个单独的页面,谷歌等...应该忽略它。

meta tag:

<meta name="robots" content="noindex, nofollow">

#4


1  

You can try to improve the text that's shown on the search results page by providing a meta description tag. However, It's the search engine's prerogative to display whatever it chooses, which is not necessarily the first 'n' words on the page.

您可以尝试通过提供元描述标记来改进搜索结果页面上显示的文本。但是,它是搜索引擎显示它所选择的任何内容的特权,这不一定是页面上的第一个“n”字。

#5


0  

I just came to think of something. I guess I could render the note with JavaScript once the page is loaded?

我只是想到了什么。我想我可以在加载页面后用JavaScript渲染笔记吗?

#6


0  

Hmm... maybe you can create a <div> with position: absolute; z-index: 99 (should be greater than 1); top: 0px; -- this should put the note at the top of the page but you could place the actual code near the bottom... search engines go linearly through the source and not by position I'd assume.

嗯...也许你可以用position:absolute创建一个

; z-index:99(应大于1);顶部:0px; - 这应该把注释放在页面的顶部,但你可以将实际代码放在底部附近...搜索引擎线性地通过源而不是我假设的位置。

Edit: And this is fail if you decide you want it located somewhere else since this is an absolute location-- it'll just break down.. :\. go with the javascript

编辑:如果你决定将它放在其他地方,这是失败的,因为这是一个绝对的位置 - 它只会分解......:\。去javascript

#7


0  

Any attempt to hide content is going to have side-effects regarding accessibility and compatibility. It seems that all you are attempting to do is control the snippet that search engines display, in which case you are better off providing an appropriate meta element description.

任何隐藏内容的企图都会对可访问性和兼容性产生副作用。您似乎只想控制搜索引擎显示的代码片段,在这种情况下,您最好提供适当的元元素描述。

#8


0  

I'm familiar with how WordPress.com works, but if you can put in stuff like Digg, Delicious badges on your blog as a third part added stuff.. then you might have a chance to do the same trick these badges uses, they inject dynamic content in your page , and you can figure how they are doing it and do the same with your custom content

我很熟悉WordPress.com的工作方式,但是如果你可以在你的博客上添加像Digg,Delicious徽章作为第三部分添加东西......那么你可能有机会做这些徽章使用的相同技巧,他们在页面中注入动态内容,您可以了解他们是如何做到的,并对您的自定义内容执行相同的操作

#1


4  

You can build that portion of the content dynamically using Javascript.

您可以使用Javascript动态构建该部分内容。

For example:

<html>
<body>
  <div id="dynContent">
  </div>
   Rest of the content here.
</body>
<script language='javascript' type='text/javascript'>
  var dyn = document.getElementById('dynContent');
  dyn.innerHTML = "Put the dynamic content here";
</script>
</html>

If you're really stuck, you can just go old school and reference an image that has your text as part of it. It's not particularly "accessibility-friendly" though.

如果你真的被卡住了,你可以去老学校并引用一个包含你的文字作为其中一部分的图像。尽管如此,它并不是特别“可访问性”。

#2


2  

Javascript. If you add your content to the site using javascript, it won't be picked up by the search engines. It's even appropriate, because you're enhancing the site, not providing additional content. Any other method of performing this will stick the content into the page. Even if you hide it using styling, it will still be in the text. Depending on your page structure, that might not be possible anyway.

的JavaScript。如果您使用javascript将内容添加到网站,搜索引擎将不会选择它。这甚至是合适的,因为您正在增强网站,而不是提供额外的内容。执行此操作的任何其他方法都会将内容粘贴到页面中。即使你使用样式隐藏它,它仍然会在文本中。根据您的页面结构,无论如何都可能无法实现。

#3


2  

If you can use an iframe, then place the content on a static html page and use the meta tag in it's head to tell the search engines to ignore it. Since it's a seperate page, google etc.. should ignore it.

如果您可以使用iframe,那么将内容放在静态html页面上并使用其中的元标记告诉搜索引擎忽略它。由于它是一个单独的页面,谷歌等...应该忽略它。

meta tag:

<meta name="robots" content="noindex, nofollow">

#4


1  

You can try to improve the text that's shown on the search results page by providing a meta description tag. However, It's the search engine's prerogative to display whatever it chooses, which is not necessarily the first 'n' words on the page.

您可以尝试通过提供元描述标记来改进搜索结果页面上显示的文本。但是,它是搜索引擎显示它所选择的任何内容的特权,这不一定是页面上的第一个“n”字。

#5


0  

I just came to think of something. I guess I could render the note with JavaScript once the page is loaded?

我只是想到了什么。我想我可以在加载页面后用JavaScript渲染笔记吗?

#6


0  

Hmm... maybe you can create a <div> with position: absolute; z-index: 99 (should be greater than 1); top: 0px; -- this should put the note at the top of the page but you could place the actual code near the bottom... search engines go linearly through the source and not by position I'd assume.

嗯...也许你可以用position:absolute创建一个

; z-index:99(应大于1);顶部:0px; - 这应该把注释放在页面的顶部,但你可以将实际代码放在底部附近...搜索引擎线性地通过源而不是我假设的位置。

Edit: And this is fail if you decide you want it located somewhere else since this is an absolute location-- it'll just break down.. :\. go with the javascript

编辑:如果你决定将它放在其他地方,这是失败的,因为这是一个绝对的位置 - 它只会分解......:\。去javascript

#7


0  

Any attempt to hide content is going to have side-effects regarding accessibility and compatibility. It seems that all you are attempting to do is control the snippet that search engines display, in which case you are better off providing an appropriate meta element description.

任何隐藏内容的企图都会对可访问性和兼容性产生副作用。您似乎只想控制搜索引擎显示的代码片段,在这种情况下,您最好提供适当的元元素描述。

#8


0  

I'm familiar with how WordPress.com works, but if you can put in stuff like Digg, Delicious badges on your blog as a third part added stuff.. then you might have a chance to do the same trick these badges uses, they inject dynamic content in your page , and you can figure how they are doing it and do the same with your custom content

我很熟悉WordPress.com的工作方式,但是如果你可以在你的博客上添加像Digg,Delicious徽章作为第三部分添加东西......那么你可能有机会做这些徽章使用的相同技巧,他们在页面中注入动态内容,您可以了解他们是如何做到的,并对您的自定义内容执行相同的操作