Latest posts

Browse topics

How To Add Open Graph Protocol For Drupal 8 Website

In today's Drupal tutorial series I will write down my notes, how to add open graph protocol for Drupal 8 website. 

The Open Graph protocol enables any web page to become a rich object in a social graph. For instance, this is used on Facebook to allow any web page to have the same functionality as any other object on Facebook. While many different technologies and schemas exist and could be combined together, there isn't a single technology which provides enough information to richly represent any web page within the social graph. The Open Graph protocol builds on these existing technologies and gives developers one thing to implement. Developer simplicity is a key goal of the Open Graph protocol which has informed many of the technical design decisions.

Make sure you check out more information about Open Graph protocol and its use: The Open Graph protocol

Also, for Drupal 7 example, you should check out this tutorial: How to add Open Graph protocol for your Drupal site

Now let's start with a basic, out of the box, Drupal 8 website, with no Open Graph enabled yet, let's try to share some of the articles on Facebook wall (no mater your personal or Facebook business page wall)

Open Graph not configured

Open Graph not configured 

Out of the box Facebook share screen works already pretty good - it takes URL and nicely gets title from it. a short description is added and of course link back to your website. Though we have missing one important element - image - there are no image. And honestly speaking I would love to have better control of what is shared in the title section, I don't want | [site:name] shared in it. And maybe I would like to have a better control of what is written in description box. Do you find the same? Then, let's fix that, and here comes in open graph protocol.

Open Graph protocol for Drupal 8

If you have followed my article on How To Override Drupal 8 Frontpage Title, you already are familiar Metatag module, which will brilliantly handle all of the required work.

  • Download and enable metatag module
  • From admin/config/search/metatag select edit Content
  • Scroll down to Open Graph settings
  • Page URL: [node:url]
  • Title: [node:title]
  • Description: [node:body]
  • For Image settings enter node[node:field_image], for displaying default image tag, if you are using custom image field, use browse available tokens to find field name

Open Graph image field settings for Drupal 8

Open Graph image field settings for Drupal 8

Adjust Open Graph settings according to your needs. Click save for now

Save and make sure to clear cache, now visit Open Graph Debugger and test your URL. Follow on screen recommendations for any issues to fix.

Now here is how this post looks if shared on Facebook again

Open Graph debugger for Drupal 8

Open Graph debugger for Drupal 8

Much better!

How to send OneSignal RSS Push Notifications Using Zapier

I've been using OneSignal to collect web push subscribers for my blog, since November 2016, by now I can brag with more than 12,000 web push subscribers for this blog. As I keep writing on many topics, I don't find it a good idea of sending RSS notification for each new article.

How To Setup Web Push Notifications For Drupal 8 (Or Any Other Site) Using OneSignal

Actually this is the thing I'm missing on OneSignal, a better segmentation. By now I keep sending web push notifications manually - once or twice per month.

Recently I started to develop another website, selling tour packages in Georgia (tourgeorgia.eu), and I did find it a good idea to collect web push subscribers there as well. Since tourgeorgia.eu has better user segmentation than my personal blog, and posts aren't published everyday, but about 5-10 times per month - an automated solution like RSS to web push subscribers seems an ideal option.

Unfortunately there is no support of setting up RSS to push subscribers directly on OneSignal, yet, though there is a great and free service Zapier, making the missing connection and allowing to setup RSS to OneSignal.

That, kind of, reminds me good old days, when I was using Twitterfeed to sync my social media accounts from RSS feed, unfortunately Twitterfeed has been shut down, but again a new service, called dlvr.it emerged and replaced it.

If you are familiar with syncing RSS to social media accounts, settings up Zapier RSS to OneSignal will be a piece of cake for you. Follow this simple tutorial to get it done:

Send OneSignal push notifications for new RSS items

Let' s keep thing automated :)

How To Setup Web Push Notifications For Drupal 8 (Or Any Other Site) Using OneSignal

Web push notifications are hot in 2017, we will see them more in future for sure. I've been using web push notifications for my personal blog and from what I've seen - it's very powerful marketing tool, allowing you to reach your audience very fast - for blogs and websites that means more returning visitors, for commerce sites that definitely means more sales.

In the past I've tried a few web push notifications providers, but at the end I've chose to stay with onesignal.com, because of it's absolutely free, no matter how many subscribers you have. Right now this blog has more than 7,000 active web push subscribers, growing at the rate of about 2,000 users per month. As my blog covers many topics, I've a pretty high unsubscribe rate too. This is the thing I'm missing in onesignal - more segmentation, as right now web push notifications are enabled on every page on this site, and at the end I have little control figuring out how to segment them.

Anyhow, recently I re-launched an older website covering tourism activities in Georgia, with promotions and deals - and then I realized - this is the right place were to use web push notifications. As this website is built by Drupal 8, in following tutorial I will provide details on how to setup web-push notifications for Drupal 8 website, but with a few minor tweaks this method should work for any other platform (WordPress, Joomla e.t.c.)

Now, if you don't have already onesginal account go and sign up for one (it's free).

Once you are registered for account, login and click on the a new add app screen to get started:

Add a new app screen ononesignal

Add a new app screen onesignal

Next, give it a name (your website's name, for example), and click on the create button

You will be asked to select a platform to configure:

Selecting platform to configure on onesignal

Selecting platform to configure on onesignal

Choose Website Push and click Next

On the next screen you will be asked to select either Google Chrome & Mozilla Firefox or Apple Safari, for the start let's choose Google Chrome and Mozilla Firefox, you will have a chance to add Apple Safari later. Click Next.

Now, let's assume that you have already https:// site enabled (if not, see how easy you could setup a free SSL from Let's Encrypt), or if you don't have yet https:// site you could choose option - My Site is not fully HTTPS

Web push notification setting screen

Web push notification setting screen

Enter your site URL and provide a link to default notification icon URL (I like to keep all of my onesignal notification icons in a separate folder on the root, and I've created a folder named onesignal, you may use different approach.

Click Save

On the next screen you will be asked to select target SKD, if you are using Wordpress you could go with WordPress selection, for Drupal or any other site we are going to choose Website Push

Select target SDK on onesignal

Select target SDK on onesignal

Click Next

You are almost done here, now it's the part to install actual code on your site, for Drupal 8:

Visit Web Push SDK Setup (HTTPS) for download files

Download and unzip the SDK files.

You should have:

manifest.json
OneSignalSDKWorker.js
OneSignalSDKUpdaterWorker.js

Upload these files to the root folder of your website

Edit manifest.json:

Change name and short_name to your site's name
Do not change the gcm_sender_id key (482941778795). This is a shared key used for push notifications (previously it required your own key, but this is no longer needed!)

{
  "name": "tourgeorgia.eu",
  "short_name": "tourgeorgia.eu",
  "start_url": "/",
  "display": "standalone",
  "gcm_sender_id": "482941778795"
}

change tourgeorgia.eu to your own website

Include and initialize the SDK

Open your html.html.twig template (if you don't have such, create it, as I didn't had html.html.twig but my template is based on bootstrap I just copied html.html.twig file from bootstartp template folder to my custom theme folder) and add following

 Include manifest.json in your themes <head> section


<!DOCTYPE html>
<html {{ html_attributes }}>
  <head>
    <head-placeholder token="{{ placeholder_token|raw }}">
    <title>{{ head_title|safe_join(' | ') }}</title>
    <css-placeholder token="{{ placeholder_token|raw }}">
    <js-placeholder token="{{ placeholder_token|raw }}">
<link rel="manifest" href="/manifest.json">
  <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>
  <script>
    var OneSignal = window.OneSignal || [];
    OneSignal.push(["init", {
      appId: "YOUR_APP_ID",
      autoRegister: false,
      notifyButton: {
        enable: true /* Set to false to hide */
      }
    }]);
  </script>
  </head>

Now, you should go back to the onesignal homepage choose your app and browse for appId, you will find it under app settings, Keys & IDs, copy and paste to head section.

If you would like to show webpush subscribe button to every user accessing your website, and kind of aggressively, asking to subscribe to push notifications, you should change autoRegister value from false to true.

HTTPS Web Push notifications enabled on Drupal 8 site

HTTPS Web Push notifications enabled on Drupal 8 site

You can try a live example here: tourgeorgia.eu

In some of the future posts I will write a brief tutorial how to actually send your first push notification using onesignal.

Mintos.com Review after 3 month investing in Peer to Peer loans

April 21st marked 3 month anniversary since  I've been actively investing on Mintos.com marketplace. In today's article I will share some of my key findings on how much some can earn here with little money. 

Update: See my latest Mintos review: Mintos.com Review 2020 (36 Month of Investing in Peer to Peer Lending)

In short - my earnings here are very humble, with last April setting personal interest payment record at EUR 25.83. Depending on your investment strategy - that's from little to a lot. For me, this seems a decent start, and I'm looking to double monthly interest payments here by the end of the year. In general, if things (interest rates) continue to be as they are, it would ask to double my investments here.

Both individuals and entities can invest through Mintos. Individual investors must be at least 18 years old, have a bank account in the European Union or third countries currently considered to have AML/CFT systems equivalent to the EU, and have their identity successfully verified by Mintos. At the moment, US citizens or taxpayers cannot register as investors at Mintos.

Affiliate link here: Signup to Mintos.com here. By using this affiliate link for registration both you and I will receive — 1% of our average daily balance which should be paid in 3 installments for the first 90 days.

In total, during the past 3 months, from invested EUR 2,361.32 I've received in interest EUR 34.12 (after deducted currency exchange fees), statically speaking that would mean 1.44% year to date yield. 

I'm still building my million dollars saving account, and for 2017 I've decided to put aside $8,561, by now I've invested about 42% from that, and about $2,500 I've invested on Mintos (in several batches). Just recently I've started to build up my dividend stock portfolio, and I've invested some money in Baltic higher dividends paying stocks. Also some little money I've put in mutual funds, again in Baltics and Eastern Europe.

Investment portfolio April 2017

Investment portfolio April 2017

Mintos makes 69.2% from my total investment portfolio, followed by stocks in Nasdaq Baltics (25%) and mutual funds (5.8%)

As you can see by now Mintos makes the biggest part from my investment strategy, though for following months this year, I'm looking to increase investments in stocks and mutual funds. I would be happy ending this year with peer to peer lending contributing to my portfolio not more than 60%. In fact, as I believe, investments in peer to peer lending shouldn't be more than 20% from total portfolio. .As I'm just starting out right now, I feel I can afford greater risk (and hopefully greater interest)

My investment strategy on Mintos.com

I continue to invest in loans only with a buy back guarantee, which means, in case if loans go past due, loan originator would buy back bad loans, helping investors to avoid losing money. I tend to invest in shorter term (up to 3 month ) loans in Georgia, but have invested in long term (72 month) loans in Baltics and Poland also.

In April I had following currency portfolio: 849.79 EUR and 4,262.84 GEL, which is a great increase if compared my investment after first month here, as said I've deposited more money in several batches on Mintos. As I'm depositing money from Georgia based bank account in Georgian lari, I need to exchange money directly on platform, paying commission fee. I try to limit my currency exchange fees on platform to 10% from interest received.  In currency exchange fees I've paid GEL 19.55 , which equals to about EUR 7.34

Investments in Georgian lari

Investments in Georgian lari gives 17% interest rate with buy back guarantee, by now most of the earnings come from Georgian lari. In total I've got 77.86 lari in interest, what equals to about EUR 29.23

Investments in GEL (as on April 30, 2017)

Investments in GEL (as on April 30, 2017)

Net annual return have increased to 15.06% as most of the loans in Georgian lari are set at 17% annually, which is a decent, due to the Georgian lari volatility against EUR and USD currencies, greater interest comes with a greater volatility, and thus it might be tempting to invest in Georgian lari only, I try to exchange Lari to EUR (allocating 10% from total interest received). Also, as I don't think such high interest rates will continue for long, I've started to invest in longer than 30 day short term loans, investing in up to 2 year loans in GEL trying to keep higher interest rate longer.

Investments in EUR

During the past 3 month I've received in interest EUR 12.68, which doesn't seems a lot right now, but on the other hand, total investment in EUR currency is relatively small.

Investments in EUR (as on April 30, 2017)

Investments in EUR (as on April 30, 2017)

I plan to increase my investments in EUR currency slowly, it would be good to see about EUR 1,200 invested after another 3 month here. Which might generate about EUR 10 monthly, with interest rates as they are now. 

Again, I'm investing in buyback loans only, to push my interest rates higher I invest heavily in long term loans, including more than 72 month. 

Postfix Send Only SMPT Mail for Drupal 8 on Ubuntu 16.04, Nginx

If you have recently installed a fresh Drupal 8 site on Ubuntu 16.04 with Nginx running on it and you are getting Unable to send e-mail. Contact the site administrator if the problem persists notice after submitting contact form, you are missing an important element for your site to functions properly.

You could be missing important information about available updates, as Drupal uses cron to sends notification e-mails once updates are available. The following written applies not only to Drupal sites, it basically applies for Nginx and Ubuntu 16.04. Since I was working with a Drupal 8 project when faced unable to send e-mail, I'm mentioning Drupal. 

Inspired by: Email not working with fresh Drupal install on Ubuntu 14.04

Anyhow, here is a simple fix, how to quickly enable mail send for your server.

Install Postfix in 3 simple steps

You will need to have access to your VPS, login with user with sudo priviligies​

sudo apt-get install postfix

Follow on screen instructions, leaving defaults 
Then, edit /etc/postfix/main.cf and set inet_interfaces to loopback-only

inet_interfaces = loopback-only

Finally, restart postfix:

sudo service postfix restart

That's it! You are good to go!