AMP

Create a live blog

Live blogs are web pages that are updated frequently throughout an on-going event, such as a sporting event or an election. In AMP, you can implement a live blog by using the amp-live-list component.

This tutorial provides a short overview of the amp-live-list component and focuses on some implementation details for live blogs, like pagination and deep linking. We'll use AMP By Example's live blog sample to illustrate implementing live blogs in AMP.

TIP – Use the LiveBlogPosting metadata markup so your blog can be integrated with third-party platform features.

Overview of amp-live-list

The amp-live-list component regularly polls the host document for new content and updates the user's browser as new items become available. This means that each time a new blog post needs to be added, the host document should be updated by the CMS to include the update in both the body and the metadata section of the page.

This is what the initial code for the blog could look like:

<amp-live-list id="my-live-list"
    data-poll-interval="15000"
    data-max-items-per-page="5">
  <button update on="tap:my-live-list.update">You have updatesbutton>
  <div items>div>
amp-live-list>

Let's look at this code:

Each amp-live-list component requires a unique id as there could be more than one on a page. In this example, we specified my-live-list as the unique id.

The data-poll-interval attribute specifies how often polls should occur; if the host document is updated, the update should be available to the user after the next time interval.

Every time a new item is added to the host document, the