Affiliately is an AMP-ready Jekyll theme for your blogs and websites.
- AMP-ready
- Responsive
- Syntax Highlighting for code
- Cover Images for homepage and blog posts
- Social Sharing via AddThis (AMP)
- Simple Navigation Menu
- Page/Post Sidebar
- Pagination
- Multiple Authors
- Featured Box/List
- Category and Tag Archives
- Include
amp-img
with<figure>
and<figcaption>
wrapper - Support WebP image format
- Lightbox (AMP)
- Include YouTube (AMP) with GA video tracking
- Disqus Comments in AMP
- Site Search via Google Custom Search Engine
- Auto-suggestion search bar
- Tracking with Google Analytics and Google Tag Manager (AMP)
- Monetize via Google Adsense and Buy Me A Coffee
- Can be easily installed using
remote_theme
- Easily Customisable
- Support deploy to Github Pages via Github Action
AMP stands for Accelerated Mobile Pages, a Google-backed project designed as an open standard for any publisher to have pages load quickly on mobile devices.
There are different ways to install the theme -
- Fork this repository and clone the forked repository.
- Update the _config.yml file as per your requirements.
- Add your posts to the _posts directory.
- Deploy to your own server or Github Pages (read Deploying to GitHub Pages with GitHub Actions ).
- Add
gem "jekyll-remote-theme"
to your Gemfile to add the theme as a dependancy. - run
bundle install
to install the plugin. - Add the following to your site's _config.yml file to activate the plugin
plugins: - jekyll-remote-theme
- Add
remote_theme: chriskyfung/amp-affiliately-jekyll-theme
to your _config.yml file to set the site theme. - Set site-wide options in your site's_config.yml.
Note: You must update the jekyll-remote-theme plugin to v0.4.2 or higher if you use Jekyll 4.0+.
You may also optionally specify a branch, tag, or commit to use by appending an @ and the Git ref (e.g., chriskyfung/amp-affiliately-jekyll-theme@v1.2.8). If you don't specify a Git ref, the master branch will be used.
This theme includes Jekyll plugins that are not in the whitelist of Github Pages. If you are going to deploy it to your Github Pages, you need to deploy it via Github Action. The Action workflow is configured in the /.github/workflows/jekyll.yml which uses helaili/jekyll-action@2.0.3. It needs access to a JEKYLL_PAT
secret set with a Personal Access Token (needs public_repo scope).
- Set up your Analytics Tracking ID in _config.yml.
- Set up your GTM AMP container ID in _config.yml.
- Set up your Adsense ID in _config.yml.
- Set up your gcse ID in _config.yml.
- Deploy disqus-amp.html to another domain or subdoamin.
- Copy the external URL link as the value of
amp_disqus_url
in _config.yml.
You can write posts just as you would in Jekyll, the only difference being that AMP has some strict guidelines on including external content.
You cannot use Markdown format or normal HTML tags. AMP provides its own custom tags for images, videos etc...
Use the picture.html
template to insert an image in the AMP format with automatically serving the image in the WebP format.
The template also wraps the image with a <figure>
tag with an optional caption element.
{% include picture.html img="welcome.jpg" height="400" width="800" ="Welcome" ="text-center" %}
Options:
- alt
- caption (support HTML codes)
- class (e.g.
text-center
) - layout (amp-img supported layouts:
fill
,fixed
,fixed-height
,flex-item
,intrinsic
,nodisplay
orresponsive
. default:intrinsic
) - lightbox (default:
true
) - link (assign a URL for the HTML a tag that wraps the amp-img tag when the key is present)
- source (
assets
,projects
orraw
)- default - get image from the
/images/posts/
directory assets
- get image from the/assets/images/
directoryprojects
- get image from the/images/projects/
directoryraw
- get image from the specified URL
- default - get image from the
You must include the following front matter variable to enable YouTube embeds.
amp:
youtube: true
To embed a single video, use the following tag to include the youtube.html
template.
{% include youtube.html id="<YOUTUBE_VIDEO_UID>" title="Welcome to Watch this Video" %}
- id required
- title optional
To embed a playlist, you must set it with both the playlist ID and the ID of the first video within the playlist.
{% include youtube.html id="<YOUTUBE_VIDEO_UID>" playlist="<YOUTUBE_PLAYLIST_UID>" title="Welcome to Watch this Video" %}
To enable syntax highlighter, you must add the following to the post front matter.
css:
syntax: true
You can assign an image (with 730×431 pixels in size) as the featured image of a post in the front matter like this:
image:
path: /assets/images/cover-image.png
- Make a copy of each featured image file in the same folder.
- Rename the copies to have a filename in form of
<filename>.thumb.<ext>
, e.g.cover-image.thumb.png
. - Rescale it to a heigth of 150px.
By default, the thumbnail of featured images is cropped at the center inside the cards of the Featured Boxes/Lists. A new variable for the thumbnail positioning was added to the theme on 2020-10-07. You can now change the image position to the left or right by appending a fit
option to the image
variable, e.g.:
image:
path: /assets/images/cover-image.png
fit: left
If the image is not at 16:9 aspect ratio, you need to define it width and height under the image
variable, e.g.:
image:
path: /assets/images/cover-image.png
width: 640
height: 480
If you do not want to render the featured image on the post page, append a hide
option to the image
variable, e.g.:
image:
path: /assets/images/cover-image.png
hide: true
If you want to remove the shadow of the featured image on the post page, append the following class to the image
variable, e.g.
image:
path: /assets/images/cover-image.png
class: shadow-none
featured: true
last_modified_at: 2020-06-20 23:36 +0000`
In the front matter, you can add your codes to the HTML header using the variable custom_header
. For example, include the script for the amp-accordion
component:
custom_head: >-
<script async custom-element="amp-accordion" src="https://cdn.ampproject.org/v0/amp-accordion-0.1.js"></script>
In the front matter, you can add your custom CSS styles to the end of the <style amp-custom>
tag inside the HTML header.
css:
custom: >
.ml-2 { margin-left: 2rem }
table { width: 100%; max-width: 400px; margin-bottom: 1.5rem; }
When you use this theme for the Github Pages of a Github project repository, it is available to show a download button or links to the repository in the sidebar of a Post.
To display the button to the project repository, declare the repository name in your _config.yml
.
repository: <USERNAME>/<PROJECT>
Also, appending the download
variable to the post front matter.
download: true
If a release exists in the repository, an additional button that links to the latest release will be shown.
Note: Authentication is required to get your repository data in order to show the release button. Please follow the docs of jekyll /github-metadata to set up your personal access token.
You can also override the latest release button by defining a URL under the download
variable, e.g.:
downlod:
url: //.../filename.zip
Some AMP components require you to specify external scripts before using them. You can specify these scripts in the head.html file in the includes directory after the already imported scripts and then use these components in any post.
AMP provides built-in validator to validate your pages so that they can rendered quickly.
You can access this validator by opening the Developer Console in your browser and adding #development=1 to any url of your site.
Example - http://localhost:4000/#development=1
If you have errors on your page, AMP will list those for you in the console. If you do not have any errors, you'll get a message "AMP Validation Successful" on your console.
Bug reports and pull requests are welcome on GitHub at https://github.com/chriskyfung/amp-affiliately-jekyll-theme/. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
To submit a pull request -
- Fork/clone the repository.
- Develop.
- Create a new branch from the master branch.
- Open a pull request on Github describing what was fixed or added.
Affiliately is based on Affiliates jekyll theme. Thank You.
The theme is available as open-source under the terms of the MIT License.