Coder Social home page Coder Social logo

asurcodes / amperage Goto Github PK

View Code? Open in Web Editor NEW
108.0 7.0 35.0 2.59 MB

Blazing fast SEO optimized GoHugo theme with native AMP, structured data, search, service workers and i18n out of the box! :zap:

Home Page: https://themes.gohugo.io/amperage/

License: MIT License

HTML 70.84% CSS 9.93% JavaScript 0.62% SCSS 18.61%
theme hugo hugo-theme amp seo pwa structured-data minimal i18n multilingual

amperage's Introduction

Amperage theme

Amperage is a theme for static site generator GoHugo. This theme provides the following features:

  • Generates native AMP pages.
  • Valid PWA out of the box.
  • Automatic structured data.
  • Service worker for asset caching, link prefetching and offline navigation.
  • Made with SEO in mind.
  • Multilanguage and i18n support.
  • Code highlighting on build time.
  • Super fast and lightweight.
  • Minimal and easily overridable styles.
  • Basic AMP shortcodes and markdown render hooks for ease of use.
  • Header menu, table of contents and related posts.
  • Uses web safe fonts by default.
  • Automatic image croping and srcset generation.
  • Social share buttons and OGP/Twitter card tags.
  • Customizable Google Analytics with gtag.
  • Configurable Adsense shortcode.
  • Comment system agnostic (Disqus example).

❯ Installation

You can use the exampleSite provided to bootstrap your new project:

git clone https://github.com/asurbernardo/amperage.git

mkdir -p new-site/themes/amperage

mv amperage/exampleSite/* new-site
mv amperage/* new-site/themes/amperage

cd new-site

hugo serve

❯ Kitchen sink

You can check out all the components of this theme here and a fully functional website using Amperage here by yours truly.

❯ Configuration

# Default language if you have a multi-language setup
DefaultContentLanguage = "en"

baseURL = "https://example.com"
theme = "amperage"
pygmentsUseClasses = true

# Number of posts shown per page
paginate = 10

# Language sections
[languages]
    [languages.en]
        contentDir = "content"
        languageName = "English"
        languageCode = "en"
        title = "Amperage theme ⚡"
        description = "This is an example page for the Amperage theme!"
        weight = 1
    [languages.es]
        contentDir = "content/spanish"
        languageName = "Español"
        languageCode = "es"
        title = "Tema Amperage ⚡"
        description = "Esta es una página de ejemplo para el tema Amperage!"
        weight = 2

# Menu elements
[[menu.main]]
    identifier = "hugo"
    name = "Hugo"
    url = "https://gohugo.io"
    weight = 10
[[menu.main]]
    identifier = "github"
    name = "GitHub"
    url = "https://github.com/asurbernardo/amperage"
    weight = 10

# Enable only tags taxonomy
[taxonomies]
    tag = "tags"

[params]
    copyright = "Amperage" # Name shown on footer copyright
    themeColor = "#333" # Theme color displayed on mobile browsers

    # Default AMP components for the whole site
    ampElements = ["amp-analytics", "amp-social-share", "amp-install-serviceworker", "amp-iframe"]

    # Google Analytics code
    googleAnalytics = "UA-128498798-1"

    # Adsense publisher code
    adsensePublisher = "ca-pub-123456789"

    # Comments Iframe URL
    commentsEmbedUrl = "https://comments.example.com"

    # Social sites for metatags
    facebookSite = "example"
    twitterSite = "@example"

    # Structured data elements
    socialProfiles = ["https://twitter.com/example","https://www.linkedin.com/in/example/","https://github.com/example"]

    alternatePageName = "Amperage example"
    organizationLogo = "/logo.png"
    organizationName = "Asur"

    publisherName = "amperage"
    publisherLogo = "/logo-amp-article.png"
    publisherLogoWidth = 600
    publisherLogoHeight = 60

# Generate json to use as search index
[outputs]
    home = [ "HTML", "RSS", "SearchIndex"]

[outputFormats]
    [outputFormats.SearchIndex]
        mediaType= "application/json"
        baseName= "search"
        isPlainText= true
        notAlternative= true

# Enable unsafe mode to be able to use HTML on markdown
[markup]
    [markup.goldmark]
        [markup.goldmark.renderer]
            unsafe = true

❯ Customize logo

To override the default logo add the svg markup on the partial layouts/partials/header/logo.html.

❯ Customize styles

To override default styles just add the file assets/custom.scss to your project and it will be transpiled, minified and appended automatically. Default styles only weight 5KB (including code highlighting), that leaves you with 45KB to further customize the theme.

❯ Enable cross-domain service worker installation

To enable cross-domain service worker you need to override the file static/install-sw.html:

<amp-install-serviceworker
  src="https://your-site.com/sw.js"
  data-iframe-src="https://your-site.com/install-sw.html"
  layout="nodisplay">
</amp-install-serviceworker>

❯ Menu links

On the menu you can set internal and external links. To set external links you can use the config.toml file:

[[menu.main]]
    identifier = "hugo"
    name = "Hugo"
    url = "https://gohugo.io"
    weight = 10
[[menu.main]]
    identifier = "github"
    name = "GitHub"
    url = "https://github.com/asurbernardo/amperage"
    weight = 10

If you want to display a page from your own site on the menu you need to add to the frontmatter of that page:

[languages.es]
    [menu.main]
        name = "Your title for the menu"
        weight = 20

This distinction is important because the service worker needs to identify the internal URLs so it can eager load them.

❯ Display ads

To enable ads you need to have an approved Adsense publisher code. Once you get one set it in the config.toml:

adsensePublisher = "ca-pub-123456789"

Now you can use the amp-ad shortcode:

{{< amp-adsense
    width="320"
    height="320"
    layout="fixed"
    slot="123456789" >}}

❯ Comments

Due to AMP requirements the comments need to be hosted in a domain different from the original. Amperage is ready to receive a URL to embed comments at the end of every post. This is to achieve a degree of agnosticy for the comment system.

Remember that to resize the iframe containing the comment box you need to send a message to the amp sentinel with the new height:

window.requestAnimationFrame(() => {
    window.parent.postMessage({
    sentinel: 'amp',
    type: 'embed-size',
    height: msg.data.height
    }, '*');
});

If you want to integrate your own comment service Amperage will add the parameters id and url to the request so you can use them on the iframe, in case you need a unique id. An example for Disqus:

var urlParams = new URLSearchParams(window.location.search);

var disqus_config = function () {
    this.page.url = urlParams.get('url');
    this.page.identifier = urlParams.get('id');
};

What I personally recommend is to use a new Github Pages project and refer it from your main site. Here you can see a fully functional example using Disqus.

❯ Contributing to Amperage

If you have a feature request or have found a bug feel free to open a new issue.

amperage's People

Contributors

0xflotus avatar asurcodes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

amperage's Issues

Meta tag parametrization

Right now the frontmatter set in the archetypes is not binded to the relevant metatags, including ogp and twitter card tags.

Breadcrumb navigation

How do I make the breadcrumb navigation displayed on the top? Sorry this might feel like a very newbie question but I couldn't find information about this anywhere.

Featured Images

Hi, I'm having some trouble adding featured images on posts (images that show up in the preview stream before someone clicks into a post).

I tried to replicate what you had here - https://github.com/asurbernardo/amperage/blob/master/exampleSite/content/test/yet-another-test-post.md - but I think I may not have added the proper configurations elsewhere, because hugo started running into compiling errors something about missing colons after [image] src = "/images/share-banner.png"

I didn't see any documentation about this and every theme seems to handle this differently, so hoping you can assist?

How to configure the theme, make it look like the demo?

Hi, Asur

I clone amperage, using the master branch,

git clone https://github.com/asurbernardo/amperage.git
cd amperage/exampleSite/ && hugo server --themesDir ../../

but it looks different from what I expect like the demo page.

and the v1 branch having problem to display post's date and tag

I like your theme, thank you for your work.

Menu adds up urls and therefore create fals paths

Hi!

Thank you for creating this beautiful theme first of all!

I am new to using Hugo and I ran into trouble with the menu bar. As soon as I click on one of the menu sections I am stuck in this location. From there on every further click just adds to the URL, e.g. www.name.com/about --> www.name.com/about/cv instead of www.name.com/cv
How do I set the menu to access the actual url instead of adding on top? I did not set urls inside the .md files, only in the config.toml in the menu section. I also did not change or add partial.

I would be very grateful if you can help me solve this problem. I was unable to locate a solution.

Best,
J

Align amp image left and right with different background mains

screenshot_161

How can we get this sort of effect with image either placed on right or left of the main content area?

Also, how can I have 3 column or 2 column blurbs like this...

screenshot_162

I am really struggling in combining AMP code with normal HTML. Any suggestions - greatly appreciated!

Not able to overwrite css.

Hello, I'm new to this Hugo game and static sites altogether and I tried all I can do but I am not able to change css. I followed instructions by you but I am unable to change it 😔. I just wanted to change font-family to verdena or roboto, What should I do, please help .

Port to Gatsby

Hey Asur,

Would you be porting this to Gatsby by any chance? Would love to have it there.

Cheers!

Feature request

1. Comment widget

https://comments.app/

2. Search widget

https://www.algolia.com/

3. amp-auto-ads

<script async custom-element="amp-auto-ads"
        src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
</script>
<amp-auto-ads type="adsense"
        data-ad-client="ca-pub-idxxxxx">
</amp-auto-ads>

"assets/custom.scss" is not transpiled

Hi, Asur.
Thank you for sharing nice theme.

I found a bug while customizing stylesheets.

As written in README.md, I created themes/amperage_custom/assets/custom.scss and ran hugo server. But styles in custom.scss were never reflected.
(amperage_custom/ is just copy of normal amperage/)

I'm using "hugo_extended_0.72.0_Windows-64bit".

Any suggestions on what I can do to get it to work?

isSet warning

WARNING: calling IsSet with unsupported type "invalid" (<nil>) will always return false.
WARNING: calling IsSet with unsupported type "string" (string) will always return false.

These warnings are coming from twitter-cards-metas.

amp-image arbitrary assetdir storage

Hi

I keep my images/videos under static/images, and I keep each image separate depending on the category and its post.
Currently, partials/blocks/image.html defines the search space as

{{ $resource := resources.Get .src }}
    {{ with $resource }}
    {{ if in (slice "jpeg" "jpg" "png" "gif" "webp" "webm") $resource.MediaType.SubType }}

Forcing me to change over 100 images location (from my old theme) to assets/
Is there's a way to load the image from the content folder using any path?

Example

image:
src: folder/folder/image.webp

This folder will be accessible from the root of public when Hugo generates the files

Muchas gracias!

Start page

Dear Asur,

is it possible to remove the post preview as default start page and use for example an image instead?

Thank you,
Jasmin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.