programing

메타 태그가 문서 본문에 있으면 어떻게됩니까?

sourcetip 2021. 1. 14. 23:45
반응형

메타 태그가 문서 본문에 있으면 어떻게됩니까?


ASP 응용 프로그램에서 작업 중이며 코드, 템플릿 및 파일이 본문 태그 외부의 내용을 변경할 수 없도록 구성되어 있습니다. 그래서 저는 다음과 같이 본문 안에 메타 태그를 삽입하는 것에 대해 생각하고 있습니다.

<!-- FEW ASP INCLUDES -->
<html>
    <head>
    <!-- FALLBACK TITLE AND DESCRIPTION -->
    <title>Default Title</title>
    <meta name="description" content="Default Description">
</head>
<body>
    <!-- SOME HTML MARKUP -->
    <div class="dynamic-content">
        <!-- InstanceBeginEditable name="dynamic-content" -->
        <!-- THIS IS WHERE I CAN WRITE ASP CODE -->
        <title><%= Page.Meta.GetTitle( yada, yada ) %></title>
        <meta name="description" content="<%= Page.Meta.GetDescription( yada, yada ) %>">
        <!-- InstanceEndEditable -->
    </div>
    <!-- SOME MORE HTML MARKUP -->
</body>
</html>

HTML 문서의 본문에 메타 태그를 넣는 것이 얼마나 좋은지 궁금합니다. 어떤 영향을 미칩니 까?

  1. 검색 엔진
  2. 브라우저

물론 이것은 HTML4.01에 따라 유효하지 않습니다 . META 태그는 HEAD 내에서만 허용 되므로 (예 : TITLE) BODY에 넣으면 기본적으로 잘못된 마크 업이 생성됩니다.

간단한 테스트에서 일부 브라우저 (예 : Firefox 3.5 및 Safari 4)는 문서 트리를 만들 때 실제로 이러한 요소를 HEAD에 넣는 것으로 보입니다. 이것은 그리 놀라운 일이 아닙니다. 브라우저는 모든 종류의 깨진 마크 업을 용인하고 해석하려고 시도하는 것으로 알려져 있습니다.

잘못된 마크 업 을 갖는 것은 좋은 생각이 아닙니다 . 브라우저의 비표준 처리로 인해 고정하기 어려운 다양한 렌더링 (및 동작) 불일치가 발생할 수 있습니다. 브라우저 추측에 의존하는 대신 표준을 따르는 것이 가장 좋습니다.

검색 엔진이 이러한 태그 수프에 어떻게 반응하는지는 모르겠지만 알아 내기 위해 실험 할 위험은 없습니다. :) 아마도 특정 정보에 대해 HEAD 태그 만 구문 분석하고 BODY 포함 태그를 모두 건너 뛸 수 있습니다. 또는 악의적 인 도박 시도 및 이러한 마크 업이 포함 된 블랙리스트 페이지로 간주 할 수도 있습니다. 누가 알아.

결론-가능하면 이것을 피하십시오.


결론 은 DOCTYPE이 금지하는 경우 가능할 마다이를 피하는 입니다. 나는 이것이 HTML5에서 확실히 허용되고 마이크로 데이터를 사용하는 경우에 매우 유용하다고 생각합니다. 예 : http://schema.org/Event


나는하지 않을 것입니다. 그 태그가가는 곳은 여기가 아니며 검색 엔진은이를 스팸으로 볼 수 있습니다. 마스터 페이지를 재구성 할 수 있다면 언제든지 head 섹션에 contentplaceholder를 추가 할 수 있습니다. 나는 그것을 사소하게 해냈다.

<asp:ContentPlaceHolder ID="HeadTags" runat="server" />

이렇게하면 페이지의 헤드 섹션에 원하는 콘텐츠를 추가 할 수 있습니다.

<asp:Content ID="Whatever" ContentPlaceHolderID="HeadTags" runat="server" >

    <meta ... >

</asp:Content>

목표가 검색 엔진 최적화 인 경우 표준을 따르고 모든 메타 태그를 <head>. 그러나 브라우저 동작이 진행되는 한 <meta>태그를 삽입해도 <body>여전히 작동합니다. 표준을 준수하는 문서에서 여러 <meta http-equiv="refresh"/>태그와 <title>태그를 사용하여이를 테스트하기로 결정했습니다 .

내 테스트 결과 :

Firefox 18, Firefox 3.6, Firefox Mobile, Chrome 24, Chrome for Mobile, Opera 12, IE6, IE8, IE10 :

  • <meta>본문의 모든 태그가 처리되었습니다.
  • <title>문서 의 첫 번째 태그는 본문에 있더라도 처리되었습니다. 후속 <title>태그는 무시되었습니다.
  • 가장 초기의 메타 새로 고침 지시문이 적용되어 둘 다 처리되었음을 의미합니다.

IE9 :

  • <title>본문의 모든 태그가 무시 된다는 점을 제외하면 위와 동일 합니다.
  • IE9 표준 모드의 IE10도 이와 같이 작동합니다.
  • IE8 표준 모드의 IE9는 IE8과 동일하게 작동 <title>하여 본문에 1 개의 태그를 허용했습니다 .

그렇다면 본문에서 메타 태그를 사용하면 어떻게됩니까? 대체로 잘 작동하는 것 같습니다. 메타 태그는 아마도 처리 될 것이므로 머리에 넣을 수 없다면 너무 걱정하지 않을 것입니다.


검색 엔진을위한 일부 메타 태그는 페이지 본문 섹션의 검색 엔진에서 인식되지 않습니다.

For example Google says that it will not honor a rel=canonical in the body of the page, but only in the head of the page. Here is what Matt Cutts from Google says:

We don’t allow rel=canonical in the BODY (because as I mentioned, people would spam that),


I would say you to use it. I found meta tags inside body on various webpages, and they are on one of top 10 searches (on google). It shows, at least to me, that searh engines don't mind if you have used this approach.

You must go ahead if there's no other way around.


I have put some meta tags into the body, but that is because of the Microdata technology. When I do not have a regular element with the info, that I need to describe the object according to the schema.org vocabulary , I set a meta tag with this content. I prefer to do it that way instead, to set an element with display:none. The way with display:none may cause more google problems instead of this, as far as I know. I agree it is not the best practice, but when I validate my document (HTML5) I pass the validation with zero errors. Also I have done this trick for a several projects and none of them has problems with google or other search engine. Even microdata improve the search engine ranking. I don't know what exactly you want to do with this meta tags into the body, because I have not saw any microdata in your code. If you need it for this approach I think it is ok, but in other cases meta elements must be in head section!


Having the META Description tag in the websites is invalid markup, however is not a huge issue as search engines can regularly find the tag where ever it is. My website does this, have a look at my HTML

http://cameras.specced.co.uk/compare/268/Canon_EOS_200D

The META is in the website BODY however it has been indexed by google and the page meta description has been set as the click though text in google search results.


meta tags can be added anywhere in the HTML.

The web crawlers can read them but the only issue is when you have to share your pages over some application like facebook messenger, whatsapp etc.

These applications only read meta tags present inside the head tag. So, the og:image, og:description properties of meta tag if placed inside body tag are not read and hence won't be displayed while sharing in such applications.

If its only for SEO purpose, you can add meta tag anywhere but it is recommended to add inside head tag only

ReferenceURL : https://stackoverflow.com/questions/1447842/what-happens-if-the-meta-tags-are-present-in-the-document-body

반응형