AMPed ghost app


#1

i believe i have ask this , but the answer before this is no…and then i found this…
if this is true
does this mean that we can use mustachejs with handlebarjs?

or can i replace post.hbs to amp.hbs completely…so every post is AMPed and not that html anymore…is that possible?

i just want to make the website fully AMPed rather than usual…

anyway, i don’t see that in the amp.hbs…does this mean amp.hbs are using handlebarsjs? so this mean AMP also work with handlerbarjs? or i overlook that amp-mustache part?


#2

From my understanding, unless you like the amp layout, there’s no need to implement the amp layout for non-amp pages. The non-amp pages generate a special meta tag which link to the amp page.

You could create a very minimal theme by taking the contents of the default amp partial and saving it as the default view (default.hbs) which should do what you want, but another option is to use url redirects


#3

Ghost is not build for this. Every AMP post needs the non-AMP counterpart, which is referenced via meta tags, just like @vikaspotluri123 mentioned. If you’d change your post.hbs to be like amp.hbs, the post content would still not get transformed into AMP HTML. That’s what the {{amp_content}} helper is doing, as soon as you have the AMP app enabled and the URL has the /amp suffix.


#4

oh, so i can’t just create theme with AMPed post.hbs?
basically what is in the amp.hbs is not handlebarjs? it is mustachejs?
oh i see…
technically there is no way to do this?


#5

i do like amp because of its speed…
before this i believe we can’t create fully AMPed website without the non-amp version?
but ampbyexample.com is completely AMP with service worker…so the performance for mobile visitor is great…
also AMP website is not that bad…i just saw some beautiful example on ampstart.com


#6

@Jehan_Musa everything in Ghost is Handlebars. The Mustache reference is only saying that the syntax is similar so you could theoretically copy/paste from a Mustache template into a Handlebars template and it would work.


#7

i hope so…
by the way, what make me confuse is…there is blogger (google blogging engine) that being transform completely AMPed by several people…
the confusing thing is that…blogger does not use mustache nor handlebar…but it does works…that what make me thing it also can work on ghost…i hope so…


#8

the confusing thing is that…blogger does not use mustache nor handlebar

I’m having trouble understanding what it is that you’re trying to do, sorry.

AMP is completely unrelated to mustache or handlebars. Mustache/Handlebars are templating engines, they generate output based on data fed into them and through any specific helpers that generate output. The output can be HTML, text, or any other syntax.

Most .hbs templates in Ghost are HTML files sprinkled with helpers and logic to control the HTML output.

There is an amp.hbs file that is used to generate the /amp page, it has AMP-friendly HTML and uses the {{amp_content}} helper to run post content through an “amperize” function to clean it up. You could theoretically modify every template in your theme to output AMP-friendly HTML and use the {{amp_content}} helper in your regular post.hbs file but I don’t know how well that will work with meta data, you’d also end up with duplicate AMP pages for every post because Ghost will automatically link the /amp version.


#9

AMP is completely unrelated to mustache or handlerbars

yes this is true,but the thing is amp only support mustache for templating…
but the other person who create AMP from blogger, simply just use the blogger tag…
so maybe in theory handlebar also can be use with AMP…

is there any way to stop ghost from automatically convert every post to amp?
(well since the post will be AMPed pages)


#10

That’s not true at all, where are you seeing that information?


#11

i found here in the list of AMP template spec

that what make me thinks mustache is the only supported


#12

by the way mr @Kevin i believe this is a thing is like re-engineering ghost…

instead, i think service worker would help…
and in amp.hbs it should have theamp-install-serviceworker
this would help whenever user go to non-amp version of the blog post (which they read on amp version)


Progressive Web App version of ghost blog (install service worker)
#13

The docs are just using mustache as an example, any templating language can be used as long as you’re outputting AMP-compatible HTML:

For example, “amp-mustache” templates are defined using Mustache.js syntax. However, any templating language has its syntax restricted and verified by the AMP validator to ensure that XSS and other issues cannot be dynamically injected into the AMP document.

No re-engineering necessary, everything is already available for you to do this via your theme. If you change every template in your theme to use AMP-compatible HTML then you can disable the AMP app to remove the /amp pages.

Having a service worker is completely independent to AMP support. Within your theme you are able to install your own service worker. amp-install-serviceworker is how you install a service worker for an AMP site compared to how you would normally install one for an HTML site.


#14

is this mean removing the amp.hbs (which generate amp version of our blog post)

and upon updating ghost blog, will it be there again (the amp.hbs file), i hope removing this file won’t break ghost blog…

by the way, is there any way to update ghost instead of using command line?
what i mean is a more user friendly…command line is more on developer i guess :sweat_smile:


#15

No, you only need to turn off the AMP app. See https://help.ghost.org/article/58-amp.

If the AMP feature is enabled and the theme doesn’t have an amp.hbs file then Ghost will use it’s built-in amp.hbs file. Ghost doesn’t touch themes when updating.

by the way, is there any way to update ghost instead of using command line?
what i mean is a more user friendly…command line is more on developer i guess :sweat_smile:

Using ghost-cli is the only recommended approach for self-hosters and that’s a lot friendlier than trying to manually download and overwrite files, install dependencies, and so on. If you want automated updates then maybe a managed Ghost(pro) site is a better fit?