Table of Contents
AMP HTML
AMP JS
AMP cache
Let's start installing! Download the plugin from the link above and install the plugin on your WordPress website. After installation, you just need to attach "/amp/" to the article page. If you don't enable a nice permalink, you can try?amp=1.
Step 2: Verify and adjust
Step 3: Verify the Schema tag
Step 4: Integrate Google Analytics with AMP WordPress plugin.
What are the main benefits of using AMP and WordPress?
How does AMP affect SEO?
Can I use AMP on my existing WordPress website?
Will AMP affect the functionality of my WordPress website?
How to customize the appearance of an AMP page?
How to check if my AMP implementation is successful?
Can I use AMP without using plugins in WordPress?
Does AMP support advertising and analytics?
Can I disable AMP for a specific post or page?
Is AMP a replacement for responsive design?
Home CMS Tutorial WordPress How to Use AMP with WordPress

How to Use AMP with WordPress

Feb 10, 2025 pm 03:47 PM

How to Use AMP with WordPress

Core points

  • Google Accelerated Mobile Pages (AMP) is a key tool to improve website speed and user experience on mobile devices without affecting advertising revenue.
  • AMP can improve SEO rankings because Google considers loading speed when ranking websites. If AMP pages have higher click-through rates and lower bounce rates due to faster loading, they will rank higher.
  • To implement AMP, developers need to create two versions of the web page: one original version for desktop users and one AMP version for mobile users. AMP does not allow form elements and third-party JavaScript, so certain features may not be available to AMP versions, such as contact forms or in-page comments.
  • Google Analytics can be integrated with AMP to track website performance. To prevent multiple analytics trackers from causing speed drops, Google uses the principle of "one measurement, multiple reports".
  • The official AMP plugin developed using Automatic/WordPress can easily integrate AMP into WordPress websites. However, be sure to verify each page and modify the plugin to ensure correct Schema tagging and Google Analytics integration.

How to Use AMP with WordPress

The Google Accelerated Mobile Pages (AMP) project was launched on February 24, 2016. With this launch, thousands of developers became active participants in the project. Countless websites now have AMP version pages, and many developers are learning to use AMP – in this case, learn how to use AMP in WordPress.

Google attaches great importance to AMP. It is also one of their search engine ranking criteria. In this way, Google makes AMP a necessity for many websites. In this article, I will provide you with detailed information about Google's accelerated mobile page project. This includes the steps to call it in your WordPress site.

What is AMP?

Some developers may not be familiar with AMP. It is a mobile-friendly framework that quickly loads your web pages on a mobile browser. It is an open source technology designed to enable website publishers to effectively improve the speed and user experience of loading content pages on mobile devices. All these enhancements will not affect advertising revenue.

If you are an experienced developer, you can achieve similar enhancements with comprehensive page loading optimizations. However, accelerating mobile pages makes these optimizations very easy to perform without spending too much time and effort on mobile layouts.

For those sites that have redoubled their SEO rankings, this will certainly add more tasks on their to-do list, as the AMP page can also enhance your website's SEO rankings. This may be the main reason why large companies also adopt AMP.

AMP project

AMP contains three main components:

  • AMP HTML
  • AMP JS
  • AMP cache

AMP HTML

It is a subset of HTML with many limitations, custom tags, and custom properties. If you are already familiar with HTML, it is not complicated to adapt to this. However, if you find any difficulties, I recommend you visit this link to learn more about how to create your AMP HTML page.

AMP JS

AMP provides a limited number of JavaScript for mobile web pages. Now, one important thing to remember about JS in AMP is that AMP does not allow third-party JavaScript.

AMP cache

Google AMP Cache is a CDN used to deliver AMP pages. You all know the core features of the content delivery network – they distribute resources to servers closer to viewers of your website. For AMP pages, this CDN will allow for a minimum load time due to possible distance delays.

The correlation of AMP logo on SEO

Back in 2016, when Google launched AMP, AdAge.com published an interview with Richard Gingras, senior director of Google News and Social Products. In that interview, he said that the use of AMP will not be directly related to your search rankings because it is not a direct factor. He then added: "All other (search engine rankings) signals need to be met, too."

However, after this clarification, everything became clearer. He said: "If we have two articles, from a signal point of view, the same score on all other characteristics (except speed), then yes, we're going to focus on the fastest one, because that's the user Discover something eye-catching. ”

Even Google does not deny the relevance of AMP websites to SEO. Speed ​​is always an influencing factor in search engine optimization. If AMP pages get more clicks and lower bounce rates due to faster loading, Google will surely rank the website higher for a better user experience.

How to AMP your website?

You must maintain two versions of the article page on the website. Original article page, for default web users, and AMP version, for potential mobile users.

Also note that AMP does not allow form elements and third-party JavaScript. This means you can't put contact forms or in-page comments in the standard implementation, as AMP is primarily used for content delivery.

  • I recommend rewriting the entire website template to deal with these limitations. For example, the CSS of an AMP page must be inlined with a page size less than 50 kb. Additionally, due to the fast loading of fonts, they should be loaded with the help of the amp-font extension in order to load the page efficiently.
  • It is recommended that multimedia be handled with caution. For images, you need to use that element along with the exact width and height. Also, if your image is a GIF, you need to use a separate amp-anim extension component.
  • For videos, there are two options. There is a custom tag for embedding videos, called amp-video. However, if you want to embed YouTube videos, you have a specific tag called amp-youtube.
  • For embedded slides, you can use amp-carousel. Apart from that, if you want to add an image lightbox, you can use amp-image-lightbox.
  • For embedded social media platforms such as Twitter, Facebook, Instagram, Pinterest, and Vine, you can use each corresponding component.
  • This is very important. Now, once everything is set up, you can use your AMP page and you have to let Google know about your AMP website. You must add a tag about your AMP page to your main post page and a canonical tag about your main page on the AMP page.
  • You can learn more about AMP tags and Schema.org metadata here. Schema.org metadata “is a requirement to qualify your content to appear in Google Search News Carousel Demos”. So if you want to succeed with Google AMP, you must set up your Schema correctly.

Is Google Analytics suitable for AMP?

Yes, of course, Analytics works for AMP. In fact, Analytics on AMP is also smart. To prevent websites from slowing down due to multiple analytics trackers, they are based on the core philosophy of “one measurement, multiple reports”. Generally, there are two ways to enable Analytics for AMP on your website.

amp-pixel element: It is a simple tag that can use GET requests to calculate page views (similar to tracking pixels).
  • amp-anayltics extension component: This component is more advanced than amp-pixel. You can use it to measure any activity on your AMP page. It allows you to specify a JSON configuration that provides detailed information about what to measure and where the report is sent.
How to use AMP on a WordPress website?

In fact, one of the easiest ways to use AMP is to implement it on your WordPress website. You can use the official plug-in developed by Automattic/WordPress.

Step 1: Install WordPress plugin

Let's start installing! Download the plugin from the link above and install the plugin on your WordPress website. After installation, you just need to attach "/amp/" to the article page. If you don't enable a nice permalink, you can try?amp=1.

Step 2: Verify and adjust

The Google search console will get the AMP version of the article page from the meta tag, which will be attached by the plugin. However, the problem is that it usually takes several days to detect such changes.

So, what should I do now? To handle these tricky situations, I recommend using a combination of Chrome verification process and search console. To use the Chrome verification process, please visit any of your AMP pages in Chrome. Then append #development=1 at the end of the URL. Now press Control Shift I to open Chrome Developer Tools.

Refresh the page and it will display "AMP verification successful" or provide a detailed list of issues that need to be fixed.

You can see that installing plugins is not enough. You must verify each data by accessing the page and repeating the above steps to benefit from accelerating mobile pages.

Step 3: Verify the Schema tag

You have learned that verifying Schema tags is essential for your AMP page. I recommend using Google's structured data testing tool to test if your page has a valid schema tag. However, I found that WordPress has some problems with displaying the logo. So I made some modifications to overcome this.

Go to plug-in, click Editor, and select AMP. Change these lines in the editor to modify the plugin.

<code>if ( $site_icon_url ) {
  $metadata['publisher']['logo'] = array(
    '@type' => 'ImageObject',
    'url' => $site_icon_url,
    'height' => self::SITE_ICON_SIZE,
    'width' => self::SITE_ICON_SIZE,
  );
}</code>
Copy after login

To:

<code>$metadata['publisher']['logo'] = array(
  '@type' => 'ImageObject',
  'url' => 'http://yourdomain.com/wp-content/uploads/logo-company.png',
  'height' => 60,
  'width' => 170,
);</code>
Copy after login

Make sure to specify the location of the logo in the URL and specify the height and width accordingly.

Step 4: Integrate Google Analytics with AMP WordPress plugin.

Now, you are almost done. However, I prefer to use Google Analytics to track statistics. The AMP WordPress plugin does not actively activate amp-analytics, but it is very easy to execute.

To enable the AMP WordPress plugin to work with Google Analytics, go to Plugins ->Editor ->Select "AMP" and add the following code to the end of it.

<code>add_action( 'amp_post_template_head', 'amp_post_template_add_analytics_js' );
function amp_post_template_add_analytics_js( $amp_template ) {
    $post_id = $amp_template->get( 'post_id' );
    ?>
     async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js">>
    <?php }

add_action( 'amp_post_template_footer', 'xyz_amp_add_analytics' );

function xyz_amp_add_analytics( $amp_template ) {
    $post_id = $amp_template->get( 'post_id' );
    ?>
    <amp-analytics> type="googleanalytics" id="analytics1"></amp-analytics>
     type="application/json">
    {
      "vars": {
        "account": "UA-XXXXX-Y"  ←(YOUR GOOGLE ANALYTICS PROPERTY ID)
      },
      "triggers": {
        "trackPageview": {
          "on": "visible",
          "request": "pageview"
        }
      }
    }
    >
    >
    <?php }
</code>
Copy after login

Make sure to change the value UA-XXXXX-Y to your own Google Analytics property ID!

After making this change, reverify your AMP page and your AMP page will be trackable.

Conclusion on Google AMP Project

Google hopes that the AMP project will provide users with a good experience. Still, the question is whether AMP can make everything super fast. The answer to this question is quite open-ended. If you don't optimize your website well, AMP will bring some significant improvements.

However, speeding up mobile pages is not a magic bullet. Technology to improve website speed is provided from the outset. AMP is just trying to combine and eliminate all the major slow loading factors and provide users with better solutions.

What do you think of AMP projects? Please share your views in the comment section below!

FAQs about using AMP in WordPress (FAQ)

What are the main benefits of using AMP and WordPress?

The main benefit of using AMP (accelerated mobile pages) with WordPress is the enhancement of the mobile browsing experience. AMP is a Google-backed project designed to make web pages load faster on mobile devices. It does this by streamlining HTML and using a thin version of CSS. This results in a significant increase in page loading speed, which can increase user engagement, retention and improve mobile SEO.

How does AMP affect SEO?

AMP can significantly improve your SEO because page loading speed is a ranking factor in Google's algorithm. By making your web pages load faster, AMP can help improve your visibility in search engine results, especially among mobile users. Additionally, Google typically highlights AMP pages in carousels highlighted in search results, providing further visibility.

Can I use AMP on my existing WordPress website?

Yes, you can use AMP on your existing WordPress website. There are several plugins available that can help you implement AMP on your WordPress website. These plugins help convert your existing posts and pages into AMP-compatible versions.

Will AMP affect the functionality of my WordPress website?

AMP limits certain HTML, CSS, and JavaScript elements to ensure fast page loading times. This means that some features of your WordPress website may not work as expected on the AMP version of your website. However, most AMP plugins offer options that can be added back to functionality by still complying with AMP standards.

How to customize the appearance of an AMP page?

CSS can be used to customize the appearance of AMP pages. However, since AMP restricts the use of certain CSS properties to ensure fast page load times, you may want to use a more streamlined approach to style it. Some WordPress AMP plugins offer built-in customization options.

How to check if my AMP implementation is successful?

You can use the AMP testing tool provided by Google to check whether your AMP implementation is successful. This tool will analyze your AMP page and report any errors that may prevent it from being provided as an AMP page in Google search results.

Can I use AMP without using plugins in WordPress?

Yes, you can implement AMP without using plugins in WordPress, but this requires a good understanding of web development and AMP standards. You need to manually create a separate AMP-compatible version of your posts and pages and manually add the necessary AMP HTML tags.

Does AMP support advertising and analytics?

Yes, AMP supports both advertising and analytics. However, because AMP restricts certain HTML, CSS, and JavaScript elements, you may need to use AMP-specific tags and scripts for advertising and analysis.

Can I disable AMP for a specific post or page?

Yes, most WordPress AMP plugins offer options to disable AMP for a specific post or page. This is very useful if you have something that doesn't work well with AMP restrictions.

Is AMP a replacement for responsive design?

No, AMP is not a replacement for responsive design. While AMP can enhance the mobile browsing experience by making pages load faster, it does not replace the need to adapt to website designs of different screen sizes. It is best to use AMP in conjunction with responsive design for the best mobile user experience.

The above is the detailed content of How to Use AMP with WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How To Begin A WordPress Blog: A Step-By-Step Guide For Beginners How To Begin A WordPress Blog: A Step-By-Step Guide For Beginners Apr 17, 2025 am 08:25 AM

Blogs are the ideal platform for people to express their opinions, opinions and opinions online. Many newbies are eager to build their own website but are hesitant to worry about technical barriers or cost issues. However, as the platform continues to evolve to meet the capabilities and needs of beginners, it is now starting to become easier than ever. This article will guide you step by step how to build a WordPress blog, from theme selection to using plugins to improve security and performance, helping you create your own website easily. Choose a blog topic and direction Before purchasing a domain name or registering a host, it is best to identify the topics you plan to cover. Personal websites can revolve around travel, cooking, product reviews, music or any hobby that sparks your interests. Focusing on areas you are truly interested in can encourage continuous writing

Is WordPress easy for beginners? Is WordPress easy for beginners? Apr 03, 2025 am 12:02 AM

WordPress is easy for beginners to get started. 1. After logging into the background, the user interface is intuitive and the simple dashboard provides all the necessary function links. 2. Basic operations include creating and editing content. The WYSIWYG editor simplifies content creation. 3. Beginners can expand website functions through plug-ins and themes, and the learning curve exists but can be mastered through practice.

How to display child categories on archive page of parent categories How to display child categories on archive page of parent categories Apr 19, 2025 pm 11:54 PM

Do you want to know how to display child categories on the parent category archive page? When you customize a classification archive page, you may need to do this to make it more useful to your visitors. In this article, we will show you how to easily display child categories on the parent category archive page. Why do subcategories appear on parent category archive page? By displaying all child categories on the parent category archive page, you can make them less generic and more useful to visitors. For example, if you run a WordPress blog about books and have a taxonomy called "Theme", you can add sub-taxonomy such as "novel", "non-fiction" so that your readers can

How to get logged in user information in WordPress for personalized results How to get logged in user information in WordPress for personalized results Apr 19, 2025 pm 11:57 PM

Recently, we showed you how to create a personalized experience for users by allowing users to save their favorite posts in a personalized library. You can take personalized results to another level by using their names in some places (i.e., welcome screens). Fortunately, WordPress makes it very easy to get information about logged in users. In this article, we will show you how to retrieve information related to the currently logged in user. We will use the get_currentuserinfo();  function. This can be used anywhere in the theme (header, footer, sidebar, page template, etc.). In order for it to work, the user must be logged in. So we need to use

How to sort posts by post expiration date in WordPress How to sort posts by post expiration date in WordPress Apr 19, 2025 pm 11:48 PM

In the past, we have shared how to use the PostExpirator plugin to expire posts in WordPress. Well, when creating the activity list website, we found this plugin to be very useful. We can easily delete expired activity lists. Secondly, thanks to this plugin, it is also very easy to sort posts by post expiration date. In this article, we will show you how to sort posts by post expiration date in WordPress. Updated code to reflect changes in the plugin to change the custom field name. Thanks Tajim for letting us know in the comments. In our specific project, we use events as custom post types. Now

How to adjust the wordpress article list How to adjust the wordpress article list Apr 20, 2025 am 10:48 AM

There are four ways to adjust the WordPress article list: use theme options, use plugins (such as Post Types Order, WP Post List, Boxy Stuff), use code (add settings in the functions.php file), or modify the WordPress database directly.

How to display query count and page loading time in WordPress How to display query count and page loading time in WordPress Apr 19, 2025 pm 11:51 PM

One of our users asked other websites how to display the number of queries and page loading time in the footer. You often see this in the footer of your website, and it may display something like: "64 queries in 1.248 seconds". In this article, we will show you how to display the number of queries and page loading time in WordPress. Just paste the following code anywhere you like in the theme file (e.g. footer.php). queriesin

Can I learn WordPress in 3 days? Can I learn WordPress in 3 days? Apr 09, 2025 am 12:16 AM

Can learn WordPress within three days. 1. Master basic knowledge, such as themes, plug-ins, etc. 2. Understand the core functions, including installation and working principles. 3. Learn basic and advanced usage through examples. 4. Understand debugging techniques and performance optimization suggestions.

See all articles