Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: nend on September 16, 2016, 12:34:52 AM

Title: Accelerated Mobile Pages (AMP)
Post by: nend on September 16, 2016, 12:34:52 AM
Today while browsing Webmaster Tools, I decided to look into AMP in more detail. I seen it before but it always thought I didn't need such a thing.

Will I decided to play around with it according to the standard and did a little buffer rewriting.
function amp_rewrite_buffer($buffer) {

// Allowed with formatting, this code needs to be better.
$ctamp = array('img','video','audio','iframe');
foreach ($ctamp as $item)
$buffer = str_replace('<'.$item, '<amp-'.$item, $buffer);

$doc = new DomDocument();
$doc->loadHTML($buffer);
$xpath = new DOMXPath($doc);

// Script is not allowed only if it is ld+json
while($node = $xpath->query('//script[@type!="application/ld+json" or not(@type)]' )->item(0))
$node->parentNode->removeChild($node);

// Not allowed elements
$remove = array('frame', 'frameset', 'object', 'param', 'applet', 'embed','form');
foreach($remove as $item)
while($node = $xpath->query('//'.$item)->item(0))
$node->parentNode->removeChild($node);

//button is allowed, no documentation on radio though.
$types = array('input','textarea','select','option');
foreach($types as $type)
while($node = $xpath->query('//input[@type="'.$type.'"]')->item(0))
$node->parentNode->removeChild($node);

// Send the doc from the dom back to the buffer
$buffer = $doc->saveHTML();

// We do this last for a reason.
$buffer = str_replace('</head>', '<script async src="https://cdn.ampproject.org/v0.js"></script><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></head>', $buffer);

return $buffer;
}

This doesn't render the page fully compliant and it doesn't look all that pretty without all that script and html charm that was removed.

After all, I was just thinking wouldn't it be easier just making a mobile template.  ::)

What are your ideas and opinions about AMP.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Arantor on September 16, 2016, 05:44:32 AM
If form isn't allowed, posting isn't going to work.

Neither is quick moderation, or logging in...
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Antes on September 16, 2016, 07:55:10 AM
Nope... http://www.xda-developers.com/accelerated-mobile-pages-what-are-they-and-how-do-i-implement-them/#index It requires too much for already established software, and I don't think it has huge difference compared to responsive. Another Google boosted project.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: nend on October 11, 2016, 09:59:26 PM
I went ahead and implemented this a while back and looks like it does have some SEO benefits on Google on mobile. I didn't use the code I posted above and went the template route.

The page below and a screen shot of the search listing on mobile, beat Wikipedia for the search phrase.
http://www.sicomm.us/a/amp/?m=97

And here is a topic view.
http://www.sicomm.us/a/amp/?t=180
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Arantor on October 12, 2016, 03:27:30 AM
You're also using personalised data which will also bias places you've already been above places you haven't been so much - as shown by the 'you went here on xxx' - which sort of makes it hard to use as evidence that, objectively, it improved things.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: nend on October 12, 2016, 11:06:24 AM
Quote from: Arantor on October 12, 2016, 03:27:30 AM
You're also using personalised data which will also bias places you've already been above places you haven't been so much - as shown by the 'you went here on xxx' - which sort of makes it hard to use as evidence that, objectively, it improved things.

True, I forgot to take that into consideration.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: nend on October 31, 2016, 09:22:55 AM
Search Console report shows increase in CTR over one month span.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: rickey29 on December 19, 2016, 09:24:40 PM
All,

Is there any AMP theme/template available for Simple Machines?  If not, is it a good idea to develop one?

Rickey
Title: Re: Accelerated Mobile Pages (AMP)
Post by: fazeMark on December 30, 2016, 06:04:07 AM
I am looking for a theme with AMP integrated. Are there any?
Title: Re: Accelerated Mobile Pages (AMP)
Post by: nend on December 30, 2016, 08:22:31 AM
Sorry I was hoping someone would of picked this up as I released all the required source code to get this working.
http://www.simplemachines.org/community/index.php?topic=549622.0

If no one is interested, I will go ahead and put this together as a modification.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: rumosdio on January 09, 2017, 04:26:32 PM
smf AMP ;)

http://www. vizszerelo-budapest.hu/amp/amp-index.html

Akit esetleg érdekel magyar nyelven tudok instrukciókat adni, vagy elérhetőséget ahhoz aki csinálta, bár ehhez a készítő beleegyezése is kelleni fog majd
Title: Re: Accelerated Mobile Pages (AMP)
Post by: nend on January 10, 2017, 12:45:13 AM
Quote from: rumosdio on January 09, 2017, 04:26:32 PM
smf AMP ;)

http://www. vizszerelo-budapest.hu/amp/amp-index.html

Akit esetleg érdekel magyar nyelven tudok instrukciókat adni, vagy elérhetőséget ahhoz aki csinálta, bár ehhez a készítő beleegyezése is kelleni fog majd

Looks like you got it going. The only issue I can see is you have your canonical's pointing to the board index and not the actual topic. The AMP documents will be penalized for having mismatched content and possibly not indexed.

I had a similiar problem a few days ago. However in my case I believe Google happened to be browsing along on two occasions and caught error pages while I was uploading new sources to the server. It was only a couple of AMP documents and I have resubmitted them, so hopefully they'll be back up soon. See attachment below.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: rumosdio on January 10, 2017, 01:18:12 AM
custom development.

It has been modified in the comments.

AMP generated from the data in the file.

We do not deceive Google, but ordinary AMP is generated.

---------------------

by google translate

egyedi fejlesztés.

a hozzászólások lett módosítva.

onnan generálódnak az adatok az AMP fájlnak.

Nem becsapjuk a google-t, hanem rendes AMP van generálva.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: neoweb on November 23, 2017, 09:25:00 AM
I want to use AMP on my forum ( https://www.neoweb.nl/forum2 ) but how do I implement it?
Google is also suggesting using an AMP plugin for wordpress... but SMF =! Wordpress :(
Title: Re: Accelerated Mobile Pages (AMP)
Post by: rickey29 on November 23, 2017, 07:10:00 PM
Quote from: neoweb on November 23, 2017, 09:25:00 AM
I want to use AMP on my forum ( https://www.neoweb.nl/forum2 ) but how do I implement it?
Google is also suggesting using an AMP plugin for wordpress... but SMF =! Wordpress :(
Look like a AMP SMF plugin is necessary.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Dzonny on November 23, 2017, 07:39:25 PM
Have you tried this one?
https://www.simplemachines.org/community/index.php?topic=549622.0
Title: Re: Accelerated Mobile Pages (AMP)
Post by: postpar on July 16, 2018, 04:58:32 PM
Forgive me for re-opening this, but the two links posted here are both dead. Have the projects been abandoned? AMP does make a difference and I would very much like to be able to use SMF with it.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Arantor on July 16, 2018, 05:03:43 PM
AMP makes a difference in that it's easier for Google to make money off your content.

A slightly acerbic (and a little hyperbole-laden) take on it - https://www.theregister.co.uk/2017/05/19/open_source_insider_google_amp_bad_bad_bad/

Though I have yet to see any evidence that this quote is wrong:
QuoteGoogle AMP is a Google project designed such that you must restrict your layout options, forgo sending visitors to your website and accept whatever analytics data Google is willing to share.

It's also fairly good at discouraging people from responding to posts on your forum...
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Xpresskonami on December 15, 2019, 03:41:05 AM
Please we need AMP for SMF. About 70% Amp now index on SEO. Any mod for this please
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Saiy on April 21, 2020, 06:42:06 AM
That would be awesome ;D
Title: Re: Accelerated Mobile Pages (AMP)
Post by: vbgamer45 on April 22, 2020, 09:20:23 AM
You can grab from https://github.com/sicommnend/SMF-AMP
Title: Re: Accelerated Mobile Pages (AMP)
Post by: spiros on May 10, 2020, 10:09:22 AM
That package gives me:
1.   Execute Modification   install.xml   Modification parse error
2.   Extract File   ./Sources/Amp.php   
3.   Extract File   ./Themes/default/Amp.template.php
Title: Re: Accelerated Mobile Pages (AMP)
Post by: vbgamer45 on May 10, 2020, 04:24:43 PM
NVM doesn't look it was finished.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Xpresskonami on June 04, 2020, 09:55:29 PM
Quote from: vbgamer45 on May 10, 2020, 04:24:43 PM
NVM doesn't look it was finished.

Do you mean the mod is not yet completed?
Title: Re: Accelerated Mobile Pages (AMP)
Post by: vbgamer45 on June 05, 2020, 12:18:50 AM
exactly not done.
Title: Re: Accelerated Mobile Pages (AMP)
Post by: Xpresskonami on June 06, 2020, 12:16:08 PM
Quote from: vbgamer45 on June 05, 2020, 12:18:50 AM
exactly not done.

Quote from: Antes on June 06, 2020, 09:27:58 AM
Before you ask

yes, this is a scuffed version of Printpage (you can see the comments in it)
no, I have no idea what I am doing...
no, there won't be a SMF 2.0 version of it -even paid-*
yes, It works...

v0.0.1 - this means something, expect nothing!

[ Demo (https://www.wowsnips.xyz/smfnext/index.php?action=amp;topic=2) ] # [ Result (https://search.google.com/test/amp?id=tUWpsZCFGYAG_UaoiMAa6g) ]

* Its licensed under MIT go port it... if you want to chip in some $$ do by my patreon

Remember if something is broken, its not my fault it was working last I checked... if its working good...

Mod licensed under: MIT

@Antes has come up with the AMP version for smf 2.1. kindly help us with the SMF 2.0 version

Thanks!!
Title: Re: Páginas móveis aceleradas (AMP)
Post by: marcosbr on June 06, 2020, 05:21:38 PM
 OK: https://www.simplemachines.org/community/index.php?topic=573591.0;topicseen