Starting point for AMP pages generated with create-amp-page and using @formanta/sass for styling. Directly deploy with netlify cms as git managed static site generator!
npm i
npm start
# or
npm run build
# test driven UI development with cypress:
npm run tdd-ui
npm run tasks
npm run clean
Open localhost:4488/defaultPage for your local page preview and change something in src/*!
Provides a basic file structure and uses the gulp build tasks of create-amp-page, with additionally: markdown and netlify cms.
- uses
.scssfiles - page data as
.jsonand/or.mdwith frontmatter - twig templates and pages
- pages by template files in
src/html/pages - pages with folders of frontmatter / collections
- using page filename for
- frontmatter files resolution
- links generation (e.g. canonical)
- use custom data, functions, filters and more
- pages by template files in
- media optimizing for png, jpg, gif, svg
- markdown to HTML generation, preinstalled markdown-it plugins for extended syntax
- basic Twig template for AMP or none AMP pages
ampEnabled = trueas template variable enables the needed AMP parts- HTML for AMP scripts
- inline CSS parts for AMP, also where the CSS is injected by gulp task
ampattribute athtmltag
- AMP Optimizer and removing unused CSS for production
- Headless Netlify CMS for site generation supported
- uses also frontmatter
- git repository management and netlify CI/CD
- identity management by netlify, github and more
- easily removable when not wanted:
- delete
public/adminfolder and remove the netlify cms part insrc/html/_base.twigblockbody_end_script
- delete
builddist folder after runningnpm run buildor whilenpm run startpublicwith general files in root likemanifest.jsonpublic/adminconfig and setup files for netlify cmssrc/apimay be used as mock apisrc/datacontains the page frontmatter and datasrc/htmlis the base for all twig templatessrc/html/pageswill be build to individual HTML pagessrc/mediamay contain imagessrc/styles/main.scssis the style sheet
This starter repository supports one click deployment on netlify, in your netlify project the identity handling must be setup - and you are ready! The template files, scripts and content schemas are already configured.
Setup identity management and adjust the email templates:
- Setup netlify project
- In netlify project, under identity: click
enable identity - Click on
Settings & Usage - Scroll to
Registration preferencesand change toInvite only - Optional, recommended: add external providers with default config like GitHub
- Scroll to
Git Gatewayand enable it - Now the general identity handling is working
- In netlify project, under identity: click
- Change email template paths in netlify, read why below
Invitation templateto:/email/invitation.htmlConfirmation templateto:/email/confirmation.htmlRecovery templateto:/email/recovery.htmlEmail change templateto:/email/email-change.html
- Invite yourself in the project's identity management
- Ready to login under
https://<your-page-name>.netlify.app/admin/, your page is published athttps://<your-page-name>.netlify.app/ - Check
netlify.tomlfor deployment settings like basic auth, edit the CMS content schema inpublic/admin/config.yml
This is an AMP boilerplate and can't use netlifys custom JS login redirect-handling, the login would be buggy: after accepting the invite you will be directed to /, this triggers the login correctly (JWT exchange) when the identity widget is loaded, but you will not be redirected to /admin/ again. To solve this, the email templates must be changed and /admin/ added between domain and # before the tokens, the templates at src/email/ are already adjusted. For ampEnabled=false the identity widget will be loaded by default in frontend, you may remove it in src/html/_base.twig. The email templates are copied to build/email as netlify needs normal HTTP access.
Take a look at the authentication documentation for netlify cms, check how to configure the cms and checkout the default widgets.
This starter will contain more and more ready to use AMP components and their CMS definitions when needed.
Universal Twig functions, used within templates, are included in create-amp-page, check out the function docs
Displays an img or amp-img tag using ampEnabled, layout defaults to 'responsive'. Set's width and height using getImage fn, adds sha1 cachebuster.
todo: srcset and image resizing support
{% embed 'blocks/image.twig' with {
src: '/media/img-01.png',
alt: 'A blog hero image',
classes: 'mb2',
layout: 'responsive',
} %}
{% endembed %}This is not really AMP compatible, or harder to develop e.g. SSL for local amp-script debugging and max. 150KB of total script sizes. Suites non-AMP pages perfectly. Use with AMP when you know what you do!
Checkout the separate create-page-starter repository, it has babel+webpack configured with Typescript and React.
This project is free software distributed under the MIT License.
See: LICENSE.
By committing your code/creating a pull request to this repository you agree to release the code under the MIT License attached to the repository.