Drupal 8 vs me

Drupal 8 vs me

Monday, March 6, 2017

Drupal8, Setting up AMP

Holy crap, somethings in life are not supposed to be easy and setting up AMP on my VPS server was one such experience.


ALWAYS BACK UP YOUR SITE FILES AND DB BEFORE SCREWING AROUND WITH INSTALLING PHP LIBRARIES.....

Three of the better tutorial out there;


# Aspects of AMP are as follows;

---- Install the appropriate Drupal repository for composer before you can use it to install drupal/amp ----

Before you can install AMP and AMP PHP Library, you need to make sure that Composer can actually pull relevant files from the Drupal repository.

Go to Using Composer to manage Drupal site dependencies and start reading; search for the heading "Define Drupal.org as the source of drupal packages" this is were the relevant info lies. 

Basically in the root folder, the composer.json file will need to have the following in it to get started with AMP and as per usual this is not there in any of my Drupal 8 Sites.
{
    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    }
}
If this is missing, all I will get is error messages in SSH (PUTTY) when running any type of "drupal/amp" command.

So I ran the Composer Command to action the Drupal Repositories;
$ composer config repositories.drupal composer https://packages.drupal.org/8
Now in my composer.json file I get what I am supposed to be getting and that is;
{
    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    }
}
Getting the above part sorted was my biggest challenge.

---- INSTALLING THE AMP MODULE & AMP PHP LIBRARY ----

So above sorted and a few checks to see that I was not getting any AMP SSH errors and I am ready for the installation.

Now after a few hours of trying to figure out Drupal Repositories on the composer.json file it is time to run;
$ composer require drupal/amp
The above command installs the AMP Module and the AMP PHP library only.

NOTE: Do not enable AMP module yet...... This is Important - do not enable the AMP module until the AMP Sub-theme has been setup.

---- INSTALLING THE AMP THEME ----

Go to AMP Theme and install as you would a normal theme.

NOTE: Please do not enable the main AMP theme......

In The AMPTheme folder (under Themes) there is a "Folder" called "ampsubtheme_example" - copy this folder to the main themes folder of Drupal as you would any sub theme. Then go to "/Admin/Appearance" within Drupal and install this ampsubtheme_example but do not set as default (Remember do not install main AMPTHEME - only the ampsubtheme_example and with the ampsubtheme_example do not set as default!!!! By just installing the ampsubtheme_example, the main AMPtheme is by default enabled).

Theme set up is now done.

---- NOW ENABLE THE AMP MODULE ----

Simple, Now go to "/Admin/Extend/" and install AMP module as usual.

---- SET AMP UP ----

Now go to "/Admin/Configuration/Content authoring/AMP configuration".

All AMP status's will be "Enable AMP in Custom Display Settings". Click on one that will have the least impact on your site for testing purposes.

This link will take you to the relevant "Mange Content Type" / "Manage Display" section of your chosen Content Type. Just below the "+ Add Group" button there is a "Custom Dispaly Settings" drop down menu. Click and just add AMP.

From this part on wards it is experimenting from your behalf.

Add "?amp" to the end of a URL to see if it is work, the theme is Bartik Based as far as I can see.

Play around with Block structures to get best results.







2 comments: