Setting up "amp-jekyll" plugin leads to an error

Looks like your error message is coming from the jekyll-analytics plugin. I tried to build your site and added --verbose --trace and got this output.

E:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/jekyll-analytics-0.1.6/lib/jekyll-analytics.rb:7:in `inject': undefined method `keys' for nil:NilClass (NoMethodError)

Disabling that plugin in the Gemfile stops the error.

I didn’t dig much deeper into your repo but did notice your _layouts/default.html is a little screwy. It needs YAML Front Matter so that could potentially bite you later.

1 Like

@flamant I have looked at your source code and found a few things that I have been able to fix (including jekyll_analytics gem). Just sent out a pull request with my changes (including screenshots as a proof that it somewhat works).

Let me know what you think! :slight_smile:

https://github.com/flamant/inger/pull/1

1 Like

Why would that be a problem in the future, can you give an example or two on the subject? I’m really curious to find out your take on that.

You have quite a bit of experience crafting your own themes (widely used BTW) and probably have seen things going wrong direction more than the rest of us! :blush:

thnx

Off hand I can’t think of one :nerd_face:

I know there was a reason I started adding empty YAML Front Matter to my default.html layouts, but completely forget why. Could have been some edge case I hit with one off my themes and this solved it.

Looking at a few other themes most don’t do it. So maybe it’s not as necessary as I led on.

nvm :blush: but if you find out what was the thing back then, pls update the thread - I would love to know what is that.

thnx!

Hi mmistake and pabloduo, thank you for your answers.
I have several questions

  1. when you say that you tried to build the site what’s the command you think of ? It’s strange, I hadn’t any issue with any kind of command considering jekyll-analytics.
  2. To remove this plugins, is the folowing process correct ?
    • uninstall the plugin by the command gem uninstall jekyll-analytics in the project directory (inger)

    • remove the gem "jekyll-analytics" command from the Gemfile

    • remove the jekyll-analytics line under DEPENDENCIES title

  3. Why the following lines have been removed from the Gemfile.lock file ?
  • jekyll-paginate (1.1.0)
  • jekyll-rss (1.0.0alpha7)
  • jekyll-paginate (~> 1.0)
  1. Why _layouts/default.html is screwy ? Can you give me an example of a proper version ?

  2. considering the _config.yml file, why should I remove url: "https://localhost". I can have that line for development purpose without breaking anything. In production environment, I will have just to replace this variable ?

  3. considering the _config.yml file, why did you add those lines ?
    jekyll_analytics:

    • GoogleAnalytics: # Add, if you want to track with Google Analytics
    • id: UA-123-456 # Required - replace with your tracking id
    • anonymizeIp: false # Optional - Default: false - set to true for anonymized tracking
      Does it replace the jekyll-analytics plugin that was removed in Gemfile ?
  4. Why did you suggest to add those lines in file ?
    Piwik: # Add, if you want to track with Piwik
    url: piwik.example.com # Required - url to piwik installation without trailing /
    siteId: “1234” # Required - replace with your piwik site id (Write id as string)

    MPulse: # Add if you want to track performance with mPulse
    apikey: XXXXX-YYYYY-ZZZZZ-AAAAA-23456 # Required - replace with your mPulse API key
    Are they other plugins to use ? And could you give me an example of their goals ?

  5. how do you understand this piece of code in footer.html file ?
    {% if page.path contains ‘_posts’ %}
    link rel=“amphtml” href="/inger/toto.html">
    {% endif %}
    What does that link tag mean and what is the purpose

Otherwise I am really confused about the src error in header.html

The scr error in your _includes/header.html was my fault…
I made that typo (and once more due to copy-pasting from the previous code) in this comment

Apologies for the typo…

Here are some answers, feel free to disagree :smile:

2. Yes, that should be enough to remove jekyll_analytics gem;

3. After you run bundle update or bundle install some of the gems that not used might be removed by the bundler and it is up to you whether to accept the change or keep Gemfile.lock intact;

5. I’ve tried to document the advice in _config.yml and again, feel free to disagree - I suggested it based on my experience with Jekyll, web servers, HTML, and CSS;

6. Since your Jekyll configuration had jekyll_analytics gem, my assumption was that you somehow need the gem and couldn’t make it work. Hence, I glanced over gem’s documentation & source code and the reason why gem wasn’t working was missing piece of configuration of jekyll_analytics in _config.yml; No, it doesn’t replace the gem - it configures it to work properly;

7. See the one above;

8. Here you can find more about link tag: https://www.w3schools.com/tags/tag_link.asp

Hope that helps :sunny:

1 Like

Thanks a lot for your answer Pavel and ashmaroli. How can I accept the answer or give you awards on jekyll talks ?

Currently, there doesn’t seem to be a system to “accept” an answer. You can however show your appreciation by clicking the “heart” symbol underneath the answer…

1 Like

+1 to click :heart: button for the posts that helped you :clinking_glasses:

and as always, it is my greatest pleasure to help Jekyll community members :star2: