구글 AMP – Link

2 min read

Amp의 Link 태그는 사용 가능한 amp 및 non-amp 페이지에 대해 Google 검색 엔진에 알리는 데 사용됩니다. 이 글에서는 Link 태그와 관련된 측면과 구글이 amp-page 및 non amp-page에 대해 결정하는 방법에 대해 자세히 설명하겠습니다.

AMP 페이지 발견

https://www.mypage.com이라는 사이트가 있다고 가정하면 뉴스 기사는 https://www.mypage.com/news/myfirstnews.html 페이지로 연결됩니다.

사용자가 구글 검색 엔진에서 검색할 때 amp-page가 아닌 페이지를 가져오는 경우 amp 페이지에 대한 참조도 가져오려면 아래와 같이 링크 태그를 사용하여 amp URL을 지정해야 합니다.

예제

비 amp 페이지의 URL

<link rel="amphtml" 
href="https://www.mypage.com/news/amp/myfirstnews_amp.html">

여기서 rel="amphtml"은 AMP가 아닌 페이지가 amp 버전을 가리키도록 지정되어 구글이 플랫폼에 따라 올바른 페이지를 표시하도록 합니다.

amp 페이지의 URL

<link rel="canonical" href="https://www.mypage.com/news/myfirstnews.html">

여기서 rel="canonical"은 html의 표준 버전을 가리키도록 amp 페이지에 지정되므로 구글은 플랫폼에 따라 올바른 버전을 표시합니다.

사이트에 amp 페이지인 페이지가 하나만 있는 경우에도 자신을 가리키는 rel="canonical"을 추가하는 것을 잊지 말아야 합니다.

<link rel="canonical" 
href="https://www.mypage.com/news/amp/myfirstnews_amp.html">

다음은 amp 페이지를 가리키는 rel="amphtml" 및 표준 html 페이지를 가리키는 rel="canonical"에 대한 참조를 보여줍니다.

구글 AMP – Link

링크를 사용한 폰트

아래와 같이 링크를 사용하여 글꼴을 외부에서 로드할 수 있습니다.

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">

허용된 출처만 허용됩니다. 글꼴을 가져올 수 있는 목록은 다음과 같습니다.

  • Fonts.com
  • Google Fonts
  • Font Awesome
  • Adobe Fonts

rel="canonical"rel="stylesheet"를 사용하는 실제 예제는 다음과 같습니다.

예제

<!doctype html>
<html ⚡ lang="ko">
<head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <title>Google AMP - Link</title>
  <link rel="canonical" href="https://googleblogamp.blogspot.com/2021/01/google-amp-link.html">
  <meta name="viewport" content="width=device-width,minimum-scale=1">
  <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
  <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
  <style amp-custom>
    h1 {color: red}
  </style>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
</head>
<body>
<h1>Amp Sample Page</h1>
<p>
  <amp-img src="images/christmas1.jpg"
           width="300" height="250" 
           layout="responsive"></amp-img>
</p> 
<p style="font-family: 'Roboto'; font-size:25px;">
  Welcome to Amp Page
</p>
</body>
</html>

위에 표시된 코드의 출력은 다음과 같습니다.

방문해주셔서 감사합니다. 즐거운 하루 되세요!

관심 있을 만한 글

  • 다음 유효성 검사 오류 메시지는 특별한 주의가 필요합니다. The tag 'img' should be replaced with an equivalent 'amp-img' tag태그 'img'을(를) 동등한 'amp-img' 태그로 교체해야 합니다. 기존의 HTML…
  • AMP 유효성 검사 오류 중에서 자바스크립트 관련 오류를 해결해 보겠습니다. Custom JavaScript is not allowed.맞춤 자바스크립트는 허용되지 않습니다. AMP에서는 성능을 보장하기 위해 자바스크립트 사용이 크게 제한됩니다. 스크립트 태그…
  • AMP 유효성 검사 오류 중에서 CSS 스타일 시트 관련 오류를 해결해 보겠습니다. The attribute 'href' in tag 'link rel=stylesheet for fonts' is set to the invalid value 'style.css'.'…
  • AMP 페이지에서 대부분의 HTML 요소를 자유롭게 사용할 수 있습니다. 그러나 일부는 제한됩니다. 일반적으로 페이지의 성능에 영향을 주는 요소, 예를 들어 외부 HTTP 요청과 관련된 요소는 금지됩니다. 이러한 경우 AMP 태그는 기존 HTML과 유사한 기능을 제공하지…
  • AMP 상용구(boilerplate)와 관련된 오류를 살펴보겠습니다. AMP 상용구와 관련된 오류는 일반적으로 문서의 끝에서 발생하며 일반적으로 다음과 같이 "The manadatory tag ..."라는 텍스트와 함께 표시됩니다: test.html:2:0 The …
  • 유효성 검사는 AMP 페이지에 문제가 있을 때 알려주며, 페이지의 어느 부분에서 문제가 발생했는지 알 수 있기 때문에 매우 유용합니다. AMP 페이지의 유효성을 검사하지 않으면 AMP 캐시에 포함되지 않습니다. 즉, 클릭함과 동시에 즉시 로드되는 페이지를 만들지 못합니다…

댓글 쓰기