• Resolved frankno

    (@frankno)


    Hello. I’m using the AMP plugin to build a theme from scratch. I know this is not best practice, but I’m trying to learn a little bit.

    The first issue I encountered is that after activating the AMP plugin, my site looks “styleless”.

    I’ve commited the theme as for now in this github repository in order to let anyone play with it and see if their result is the same.

    I’m still gonna try to explain my process:

    I’ve created a new theme and added a few stuff to functions.php, most notably:

    # add AMP support
    add_theme_support( 'amp' );
    
    /*  ... */
    
    # Register styles
    function weblike_enqueue_styles(){
      wp_enqueue_style( 'teutonic', get_template_directory_uri() . '/css/includes/teutonic.css' );
      wp_enqueue_style( 'weblike', get_template_directory_uri() . '/css/main.css' );
    }
    add_action( 'wp_enqueue_scripts', 'weblike_enqueue_styles' );
    
    
    # Disable admin toolbar
    add_filter('show_admin_bar', '__return_false');
    

    I’ve registered two stylesheets: the teutonic CSS and a main stylesheet with very little code (only one CSS class).

    Note: This issue still holds after disabling teutonic. My first though is that teutonic was including some unsupported AMP features (it has a lot of css variables and all text sizes are calc()‘d).

    Now after doing this, my header.php looks like this (the head tag is almost exactly as the one in this theme I’m using as a guide: ampnews/header.php).

    This should make my site AMP right away… right? (That’s what I understand the plugin does… at least)

    Yet…
    – the styles are disabled completely in my site.
    – the most familiar thing with an inline style is this piece of code: <noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript> and this one
    <style amp-custom></style> (an empty script tag)
    – there are no style="" attributes
    – of course, all styles appear inmediately after disabling the plugin

    I would post a screenshot but I’m too lazy to upload it to an external web service :sorry:

    • This topic was modified 6 years, 8 months ago by frankno.
    • This topic was modified 6 years, 8 months ago by frankno.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @frankno,
    Wow, that’s great that you’re creating a Native AMP theme.

    When using your theme, I also saw that the styling didn’t appear:
    No styling weblike

    But when using the upcoming AMP plugin version 1.0 of this plugin, it looked like there was some styling:

    Weblike amp plugin
    https://github.com/Automattic/amp-wp#10-unreleased

    Version 1.0 handles styling better, and it has tree-shaking to try to avoid stripping styling that’s over the 50 KB limit.

    Version 1.0 isn’t yet ready for production. In the meantime, you might try enqueuing the CSS, instead of using the @import. But I’m not sure if that’ll fix it.

    Thread Starter frankno

    (@frankno)

    Thanks @ryankienstra. Indeed, the webpage I was working on had only a few basic styles. So with the new version of the AMP plug-in, the styles look exactly as they’re supposed to look… Yay!

    This is exiting, it talks great about the plug-in that it can handle complex stylesheets with lots of –vars and calc()s.

    Thanks ?

    Thread Starter frankno

    (@frankno)

    Hi, I was trying the new plug-in version just now (I hadn’t had the time earlier), and even with the new 1.0 version, my site doesn’t load with any CSS at all. I’ve also tried with other themes, like Twenty Fifteen, Twenty Seventeen… And there’s no CSS either.

    Like before, the source code of my site shows an empty <style amp-custom=""></style> tag

    This is the screen that show the current version of the plug-in

    View post on imgur.com


    Edit: I deleted the previous persion of the plug-in, downloaded the code from GitHub’s dev branch and run composer install. If you need any reference of my set-up, I might possibly update the SQL database export file somewhere? May that be useful?

    • This reply was modified 6 years, 7 months ago by frankno. Reason: Base64 images are not supported
    • This reply was modified 6 years, 7 months ago by frankno.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CSS doesn’t load’ is closed to new replies.