Skip to content
This drupal module is meant to make it easier for you to add cool social media links to your organisation - right on your Drupal Website!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This module is meant to make it easier for you to add cool social media links to your organisation - right on your Drupal Website!




Clone the repository to your system, and copy the files into your Drupal Installation at \modules\custom\sociallinks\.


Navigate to Manage → Extend → Custom and check SocialLinks.


Click on Install. You are now ready to start using SocialLinks.


You can configure the module to specify the URLs for the social media links in the grid.

Note: You must be an administrator for this.


Navigate to Manage → Configuration → Development → SocialLinks Configuration

This will lead you to /admin/config/Social/config.



In each text field, enter the required value (usually username) for each corresponding website.


Click on Save Configuration. You are done!


Head on to /Social from your website to see SocialLinks in action.

For a working demo, click here.

How SocialLinks was made

SocialLinks was made entirely by me, and the only external library I used was FontAwesome for the Social Media Website Icons.

I followed some Drupal 8 Module Tutorials from the following links, to get acquainted with Drupal (as I never worked on it before) to get a start.

  1. Drupal 8 Docs
  3. Red Crackle
  4. Cloud Ways

For reference to a simple working model to understand the skeleton of a module, I referred to Sidharrell's D8HW Example.

Directory Structure


The module consists of the basic .info.yml to provide information about the module while installing it, to specify the path to be linked from Configuration section of admin pages, and a .routing.yml to specify what should be displayed at which path (the content and the settings) and for whom.

One of the problems I experienced was that the link for SocialLinks Configuration in Configuration page was taking me to /Social where the module's content lives, not the settings - even though I had specified /admin/config/Social/config in .routing.yml.

The problem was finally solved when I changed route_name under sociallinks.admin to sociallinks.config (which is routed to configuration), which I had mistakenly put to sociallinks.content (which routes to the content page).

Further, there is a GNU LICENSE and needed for the Git repository.

The module consists of 2 components - a controller (sociallinksController) and a form (sociallinksConfigForm).

The Controller contains the markup that is returned to the page. This included the HTML markup that makes the icons and the hyperlinks, and some CSS within <style></style> and a link to the FontAwesome library. This code was taken from a fiddle I created myself at JSFiddle earlier.

The Form consists of the Configuration Form that allows Administrators to customize the links to be displayed. It has fields for each social media website and finally a submitForm() function.

The problem I faced in this was to use the Configuration Settings Given in the Form within my Controller, to alter the markup according to the settings.

I firstly used

(for the value to facebook)

but this returned nothing. I noticed that I hadn't imported the required modules from Drupal Core.

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

This didn't work either and it finally did when I changed the above segment to


Finally, there is a .config.yml at config → install to put some conventional default configuration.

You can’t perform that action at this time.