<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[LimoenGroen - Medium]]></title>
        <description><![CDATA[An experienced Drupal company based in Amsterdam with a strong focus on building accessible websites that last at least 5 years. - Medium]]></description>
        <link>https://medium.com/limoengroen?source=rss----a485923d164a---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>LimoenGroen - Medium</title>
            <link>https://medium.com/limoengroen?source=rss----a485923d164a---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:22:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/limoengroen" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Lazy coding: exploring ‘drush generate’]]></title>
            <link>https://medium.com/limoengroen/lazy-coding-exploring-drush-generate-dcb2cee22bf2?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/dcb2cee22bf2</guid>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[drupal-8]]></category>
            <category><![CDATA[drush]]></category>
            <dc:creator><![CDATA[Louis Nagtegaal]]></dc:creator>
            <pubDate>Thu, 05 May 2022 13:19:34 GMT</pubDate>
            <atom:updated>2022-05-06T09:26:58.379Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pl-_P0JH8J0VWwgymGThCA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@agforl24">Tai Bui</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p>For Drupal site builders <em>drush</em> is the Swiss army knife that can be used for a wide range of purposes, from simply clearing the cache to updating translations or even install a complete new site.</p><p>In the more recent versions of <em>drush</em> a command was added that makes <em>drush</em> also interesting for Drupal developers. This command, <em>generate</em>, makes it easy to generate boilerplate code for modules, plugins, services and much more. And it is even possible to extend existing custom (or contrib) modules with a generator.</p><p>The generate command uses the <a href="https://github.com/Chi-teck/drupal-code-generator">chi-teck/drupal-code-generator-library</a> to generate the code and if you are looking for examples how to write your own generator, or are just curious about how this works, the <em>vendor/chi-teck/drupal-code-generator/templates</em> and <em>vendor/chi-teck/drupal-code-generator/src/Command </em>directories are a good place to start.</p><p>The great strength of the <em>generate</em> command is the way it creates code according to the answers to a number of questions asked when run. These questions usually include the machine name of the module you want to add the code to, the machine name of the plugin that is created etcetera, but where applicable also questions about which services you want to inject or which routes you want to add. The inner workings of this will be discussed later when we write our own <em>generate</em>-command, but first let’s take a look at what is included by default.</p><h3>Default generators</h3><p>To get a list of all the generators included by default simply issue the generate command without an argument:</p><pre>$ drush generate</pre><p>This will show a list of all the generators, divided into a number of categories. I will not discuss the full list here, you can check it out for yourself, but will highlight a number of categories and generators.</p><h3>The _global category</h3><p>In the global category there are a number of generators unrelated to specific Drupal entities like plugins or modules (although it also seems to be the “I did not know where to put it”-category). The most interesting generators (at least in <em>my</em> daily work) here are:</p><h4>controller</h4><p>This will generate a custom controller and all the files needed to get it functioning. The best way to see how this works is by using the command yourself, but to give you an idea, this is the output as shown on the command line:</p><pre>$ drush generate controller<br>​<br>Welcome to controller generator!<br>––––––––––––––––––––––––––––––––––<br>​<br>Module machine name:<br>➤ dclg_base<br>​<br>Class [DclgBaseController]:<br>➤ <br>​<br>Would you like to inject dependencies? [No]:<br>➤ yes<br>​<br>Type the service name or use arrows up/down. Press enter to continue:<br>➤ entity_type.manager<br>​<br>Type the service name or use arrows up/down. Press enter to continue:<br>➤ <br>​<br>Would you like to create a route for this controller? [Yes]:<br>➤ <br>​<br>Route name [dclg_base.example]:<br>➤ <br>​<br>Route path [/dclg-base/example]:<br>➤ <br>​<br>Route title [Example]:<br>➤ <br>​<br>Route permission [access content]:<br>➤ <br>​<br>The following directories and files have been created or updated:<br>–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––<br>• modules/custom/dclg_base/dclg_base.routing.yml<br>• modules/custom/dclg_base/src/Controller/DclgBaseController.php</pre><p>If you are curious about why these specific questions are asked in this case, take a look at the Controller class in <em>vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Controller.php.</em></p><p>When you run the command yourself you wil notice that a number of questions, like <em>Module machine name </em>and <em>Type the service name </em>provide auto completion to make it easy to find the correct name.</p><p>Of course the code generated is boilerplate code so you still have to write the code that actually does something useful (the fun bit!), but it handles a lot of the nitpicking required to, for example, inject dependencies. And even the comments required by the Drupal coding standards are added.</p><h4>javascript</h4><p>This generates an “empty” javascript file but with all the different brackets (I’m much more of a backend developer…) in place and with an example behavior, like this:</p><pre><em>/**<br> * @file<br> * Drupal Coding LG Base module behaviors.<br> */<br><br></em>(function ($, Drupal) {<br><br>  &#39;use strict&#39;;<br><br>  <em>/**<br>   * Behavior description.<br>   */<br>  </em>Drupal.behaviors.dclgBase = {<br>    attach: function (context, settings) {<br><br>      console.log(&#39;It works!&#39;);<br><br>    }<br>  };<br><br>} (jQuery, Drupal));</pre><h4>hook</h4><p>When you use an IDE like PHPStorm, adding hooks is also possible from within the editor. drush generate hook has the advantage that it also generates any extra files like [module_name].views_execution.inc file for views hooks and adds code examples.</p><p>But, and this is a rather large drawback, unlike PHPStorm for example, it does not include the hooks defined by contrib and custom modules. Only the hooks defined in <em>vendor/chi-teck/drupal-code-generator/templates/d8/hook </em>are available.</p><h3>The form category</h3><h4>form-config</h4><p>No one likes hard-coded settings, but creating a settings form can be a bit of a hassle. drush generate form-config takes away the hassle and not only creates the settings form but also adds (or alters if it already exists) the <em>routing.yml</em> and <em>links.menu.yml</em> you need to make the settings form accessible.</p><h4>form-simple</h4><p>The drush generate form-simple commands adds a complete (with submit and validation functions) custom form and, when requested, even adds a route and injects dependencies.</p><h3>The module category</h3><p>In the module category the main command is</p><h4>module-standard</h4><p>This generates a complete Drupal module, with optionally the basic files for a custom module:</p><ul><li>An install file.</li><li>A libraries file.</li><li>Permissions.</li><li>Event subscribers.</li><li>A block-plugin.</li><li>A controller.</li><li>A settings form.</li></ul><p>This generator shows another important feature of drush generate, you can have one generator call other ones and so can reduce the amount of work necessary to create complex code structures.</p><h3>The plugin category</h3><p>Since Drupal 8 plugins are the backbone for a large part of the functionality in Drupal. With drush generate you can quickly create the main structure for simple plugins like a queueworker, but also complex plugins, like a block (with optionally a settings form, dependency injection and access control) and even a ckeditor-plugin including the necessary Javascript files and a (standard) icon, can be generated.</p><p>In the current version 20 types of plugins are supported by default.</p><p>In the section about how to create your own generate-command we will add a plugin-generator and take a more in depth look at how this works.</p><h3>The service category</h3><p>Another important concept since Drupal 8 are services. drush generate by default includes 16 generators for services, including service-event-subscriber , service-route-subscriber and service-access-checker and also:</p><h4>service-custom</h4><p>The drush generate service-custom-command will create the class file in the src directory and also will add the services.yml to the module or alter the existing one. It also gives you the option to inject any existing services and adds these to the constructor and the services.yml as well.</p><h3>The yml category</h3><p>In the Yml-section 12 generators are listed that you can use to add yaml-files for things like permissions, routing or services to custom modules or add breakpoints and libraries to existing themes.</p><p>The output of the generators is rather simple, but still, it is a better way then adding them by copy/paste from your latest project…</p><h3>Creating a custom generator</h3><p>As mentioned above the list of available generators is quite extensive, so why add your own? A possible reason is that you maintain or extensively use a Drupal module and want to add a generator to save time.</p><p>In this example we will use the <a href="https://www.drupal.org/project/extra_field">Extra Field</a> -module as base for our generator. The main reason for this is that I am using this module quite frequently, but it is also a good candidate because the code that needs to be generated is quite straightforward.</p><p>The process of adding a generator (alas there is no drush generate generator-command) requires a number of steps. First of all we need to tell drush our module has its own drush commands, secondly we have to implement the command and define the template(s) for the code we want to generate.</p><h4>Drush commands</h4><p>To generate the boiler-template for the drush-commands we use</p><p>ddrush generate drush-command-file</p><p>This will generate a drush.services.yml file and a class in src/Commands that extends the DrushCommands-class.</p><p>In our case we need the command-class because it must be present in de drush.services.yml ) but we do not need the methods the drush-command-file-generator adds because we are extending the existing generate-command. So we can simply delete the methods, but keep the class file.</p><h4>The generator class</h4><p>To add our command we have to add a class that extends the BaseGenerator-class in the src/Generators-directory inside our module.</p><p>Of course we have to define the name space and we add a number of helper-classes we need, so we start with:</p><pre>namespace Drupal\extra_field\Generators;<br>​<br>use DrupalCodeGenerator\Command\BaseGenerator;<br>use DrupalCodeGenerator\Utils;<br>use Symfony\Component\Console\Input\InputInterface;<br>use Symfony\Component\Console\Output\OutputInterface;<br>use Symfony\Component\Console\Question\ConfirmationQuestion;</pre><p>In the class we have to set a number of properties to define our command:</p><pre>class ExtraFieldGenerator extends BaseGenerator{<br>  <br>    protected $name = &#39;plugin:extra-field-generator&#39;;<br>    protected $description = &#39;Generates an extra field plugin.&#39;;<br>    protected $alias = &#39;extra-field&#39;;<br>    protected $templatePath = __DIR__;</pre><p>The $name, $alias and $description is what we see if we run drush generate, and because the $name is prefixed with plugin: the command is shown in the &#39;plugin&#39;-section as:</p><p>plugin-extra-field-generator (extra-field) Generates an extra field plugin.</p><p>The $templatePath defines the directory in which the template (see <strong>The generator template</strong>) resides. The default is the template directory of the library in the vendor directory:</p><p>vendor/chi-teck/drupal-code-generator/templates</p><p>But in our case we want to include the template inside the <em>src/Generators </em>directory and we use the PHP magic constant ‘__DIR__’ which will point to that directory.</p><p>The only method we are required to implement is the interact-method in which is determined which questions are asked when the command runs and which files are generated.</p><p>First we define a group of default questions</p><pre>// Determine the module the plugin must be added to.    <br>$questions = Utils::moduleQuestions();<br>// Determine the label, id and class name for the plugin.<br>$questions += Utils::pluginQuestions(&#39;&#39;);<br>// Ask the questions.<br> $vars = &amp;$this-&gt;collectVars($input, $output, $questions);</pre><p>Optionally we want the possibility to inject one or more services, which is handled by</p><pre>// Check if user want to adde services.<br>$di_question = new ConfirmationQuestion(&#39;Would you like to inject dependencies?&#39;, FALSE);<br>if ($this-&gt;ask($input, $output, $di_question)) {<br>   // Add services.<br>   $this-&gt;collectServices($input, $output);<br>}</pre><p>The above code sets the variables and after that we only have to determine where the code is added and which template is used with:</p><pre>$this-&gt;addFile()<br>  -&gt;path(&#39;src/Plugin/ExtraField/Display/{class}.php&#39;)<br>  -&gt;template(&#39;extra-field-generator.twig&#39;);</pre><p>This also creates the necessary directories if they are not yet present.</p><p>So, the complete generator class looks like this:</p><pre>&lt;?php<br><br>namespace Drupal\extra_field\Generators;<br><br>use DrupalCodeGenerator\Command\BaseGenerator;<br>use DrupalCodeGenerator\Utils;<br>use Symfony\Component\Console\Input\InputInterface;<br>use Symfony\Component\Console\Output\OutputInterface;<br>use Symfony\Component\Console\Question\ConfirmationQuestion;<br><br>class ExtraFieldGenerator extends BaseGenerator{<br>  protected $name = &#39;plugin:extra-field-generator&#39;;<br>  protected $description = &#39;Generates an extra field plugin.&#39;;<br>  protected $alias = &#39;extra-field&#39;;<br>  protected $templatePath = <em>__DIR__</em>;<br><br>  <em>/**<br>   * {@inheritdoc}<br>   */<br>  </em>protected function interact(InputInterface $input, OutputInterface $output)<br>  {<br>    $questions = Utils::<em>moduleQuestions</em>();<br>    $questions += Utils::<em>pluginQuestions</em>(&#39;&#39;);<br><br>    $vars = &amp;$this-&gt;collectVars($input, $output, $questions);<br><br>    $di_question = new ConfirmationQuestion(&#39;Would you like to inject dependencies?&#39;, FALSE);<br>    if ($this-&gt;ask($input, $output, $di_question)) {<br>      $this-&gt;collectServices($input, $output);<br>    }<br><br>    $this-&gt;addFile()<br>      -&gt;path(&#39;src/Plugin/ExtraField/Display/{class}.php&#39;)<br>      -&gt;template(&#39;extra-field-generator.twig&#39;);<br>  }<br>}</pre><h4>Generator template, the basics</h4><p>The generator template is a twig-file that is rendered in the location defined by the path in the addFile-call in the generator-class above.</p><p>In this template we define the basic code we need for our generated plugin and we can use the variables set by the questions in the command file. Because Twig is used the code will closely resemble the code used in templates within a theme in html.twig templates.</p><p>If for example we need to define the namespace we use the machine name set in Utils::moduleQuestions() with:</p><pre>namespace Drupal\{{ machine_name }}\Plugin\ExtraField\Display;</pre><p>In the annotation and the class name we use the variables set in Utils::pluginQuestions(&#39;&#39;)</p><pre>/**<br>* Displays {{ plugin_label }}.<br>*<br>* @ExtraFieldDisplay(<br>*   id = &quot;{{ plugin_id }}&quot;,<br>*   label = @Translation(&quot;{{ plugin_label }}&quot;),<br>*   bundles = {<br>*     &quot;node.*&quot;,<br>*   }<br>* )<br>*/<br>class {{ class }} extends ExtraFieldDisplayFormattedBase implements ContainerFactoryPluginInterface {</pre><p>And we define the boiler-template code we want to add with some static text</p><pre>/**<br>* {@inheritDoc}<br>*/<br>public function viewElements(ContentEntityInterface $entity) {<br>  $build =[];<br>  // TODO: build render array to return.<br>  return $build;<br>}</pre><p>Besides simply using variables other twig-constructs like</p><pre>{% if variable %}<br>{% for variable in variables %}</pre><p>also can be used and even macros can be defined. See the <a href="https://twig.symfony.com/doc/2.x/templates.html">Twig-documentation</a> for a complete list.</p><h4>Generator template, including other twigs</h4><p>In the basics described above we left out the part about the dependency injection. The variables for this part are collected in the collectServices-call in the command class and to render the code-parts for the services we include the di.twig with</p><pre>{% import &#39;/lib/di.twig&#39; as di %}</pre><p>By combining static text with variables and macros defined in the library /lib/di.twig we can create exactly the code we want to.</p><p>The full template looks like this:</p><pre>{% import &#39;/lib/di.twig&#39; as di %}<br>&lt;?php</pre><pre>namespace Drupal\{{ machine_name }}\Plugin\ExtraField\Display;</pre><pre>{% sort %}<br>use Drupal\Core\Controller\ControllerBase;<br>  {% if services %}<br>use Symfony\Component\DependencyInjection\ContainerInterface;<br>{{ di.use(services) }}<br>  {% endif %}<br>{% endsort %}</pre><pre>use Drupal\Core\Entity\ContentEntityInterface;<br>use Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase;</pre><pre>/**<br>* Displays {{ plugin_label }}.<br>*<br>* <a href="http://twitter.com/ExtraFieldDisplay">@ExtraFieldDisplay</a>(<br>*   id = &quot;{{ plugin_id }}&quot;,<br>*   label = <a href="http://twitter.com/Translation">@Translation</a>(&quot;{{ plugin_label }}&quot;),<br>*   bundles = {<br>*     &quot;node.*&quot;,<br>*   }<br>* )<br>*/<br>class {{ class }} extends ExtraFieldDisplayFormattedBase implements ContainerFactoryPluginInterface {</pre><pre>{% if services %}<br>{{ di.properties(services) }}</pre><pre>/**<br>   * The constructor.<br>   *<br>{{ di.annotation(services) }}<br>   */<br>  public function __construct({{ di.signature(services) }}) {<br>{{ di.assignment(services) }}<br>  }</pre><pre>/**<br>   * {<a href="http://twitter.com/inheritdoc">@inheritdoc</a>}<br>   */<br>  public static function create(ContainerInterface $container) {<br>    return new static(<br>{{ di.container(services) }}<br>    );<br>  }</pre><pre>{% endif %}<br>  /**<br>  * {<a href="http://twitter.com/inheritDoc">@inheritDoc</a>}<br>  */<br>  public function viewElements(ContentEntityInterface $entity) {<br>  $build =[];<br>  // TODO: build render array to return.<br>  return $build;<br>  }<br>}</pre><h3>Conclusion</h3><p>Of course being ‘lazy’ is not per se a good quality for a developer. But just like using a proper IDE can make your life so much easier compared to using vi , using a tool like drush generate can make your life much easier. You don’t have to concern yourself with a large part of the bookkeeping normally necessary when creating complex code with, for example, dependency injection or routes and, as a bonus, often get sample code too.</p><p>In short, it makes it possible to concentrate on the fun bits of Drupal-programing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcb2cee22bf2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/lazy-coding-exploring-drush-generate-dcb2cee22bf2">Lazy coding: exploring ‘drush generate’</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drupal Migrations in ddev]]></title>
            <link>https://medium.com/limoengroen/drupal-migrations-in-ddev-794bb9800546?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/794bb9800546</guid>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[dev-d]]></category>
            <category><![CDATA[drupal-migration]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Louis Nagtegaal]]></dc:creator>
            <pubDate>Mon, 28 Mar 2022 12:30:17 GMT</pubDate>
            <atom:updated>2022-03-28T12:27:39.925Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*akW9aXuh8bpftAqGQEzg0w.jpeg" /><figcaption>Photo: <a href="https://unsplash.com/@oskaryil"><strong>Oskar Yildiz</strong></a></figcaption></figure><p>Drupal migrations belong to the hardest things to debug. First of all you usually have to deal with large amounts of data, since migrating 5 or 10 or 25 items is best done by hand, and yes, that means copy / paste actions. But running a migration of thousands of items and waiting a long time before discovering that you used a wrong target field is not very productive, and if you use the ‘limit’-option during a migration you will miss all that new content that was added last, with all the new features that were added.</p><p>Luckily there is a solution for this, and for the problem this solution causes.</p><p>Another problem when running a local site in ddev is getting debugging to work with PHPStorm for a Drush command. I will show what we did to make sure our breakpoints really, well, break.</p><p>While configuring a number of migrations I found that not all documentation found on the web is, let us say, completely up to date or accurate. I don’t think I can solve this, but will give a number of examples that worked for me.</p><h3>Lots of data</h3><p>So what to do if you have lots of data and do not want to watch a command prompt with a slowly increasing percentage for hours? As mentioned before, using the limit option wil not only limit the number of items you import but also the variation in the set of imported data. A solution we use here at LimoenGroen is to use a custom source plugin and alter the query used to get the source items.</p><p>Thanks to OO-inheritance doing so is remarkably simple as shown in this code fragment which builds upon the core D7 node source plugin. We will start with a basic skeleton like this:</p><pre>&lt;?php<br>​<br>namespace Drupal\test_migrate\Plugin\migrate\source;<br>​<br>use Drupal\node\Plugin\migrate\source\d7\Node;<br>​<br>/**<br> * Class TestSource<br> *<br> * @package Drupal\test\Plugin\migrate\source<br> *<br> *  * @MigrateSource(<br> *   id = &#39;d7_node_complete_test&#39;,<br> *   source_module = &#39;node&#39;<br> * )<br> */<br> */<br>class TestSource extends Node{<br>  /**<br>   * {@inheritdoc}<br>   */<br>  public function query() {<br>    $query = parent::query();<br>    return $query;<br>  }<br>   <br>  /**<br>   * {@inheritdoc}<br>   */<br>  public function prepareRow(Row $row) {<br>    // Allow parent classes to ignore rows.<br>    if (parent::prepareRow($row) === FALSE) {<br>      return FALSE;<br>    } <br>}</pre><p>First of all we want to ensure we get a limited but representative subset. We achieve this by adding a setting to the Drupal settings file and use this to reduce the number of items. In the settings file we add:</p><pre>$settings[&#39;test_migrate_reduce_factor&#39;] = 50;</pre><p>And we adjust the query-function like this:</p><pre>public function query() {<br>    $query = parent::query();<br>    $reduce_factor = Settings::get(&#39;test_migrate_reduce_factor&#39;);<br>    if ($reduce_factor &amp;&amp; is_int($reduce_factor)) {<br>      $query-&gt;where(&#39;MOD(n.nid, :reduce_factor) = 0&#39;, [&#39;:reduce_factor&#39; =&gt; $reduce_factor]);<br>    }<br>    return $query;<br>  }</pre><p>By adding a modulus (‘MOD’) clause to the query, we make sure that only each n-th (in our example 50th) source item is included in the migration. Using a setting variable is not mandatory, but it makes it easy to test different subsets of source items.</p><p>This however presents us with a new problem, especially when updating content: which content was updated? A quick solution for this is adding a second setting</p><pre>$settings[&#39;test_migrate_debug_source_field&#39;] = &#39;title&#39;;</pre><p>and adjust the prepareRow-function like this:</p><pre>public function prepareRow(Row $row) {<br>    // Allow parent classes to ignore rows.<br>    if (parent::prepareRow($row) === FALSE) {<br>      return FALSE;<br>    } <br>    $debug_property = Settings::get(&#39;test_migrate_debug_source_field&#39;);<br>    if (!empty($debug_property)) {<br>      $field = $row-&gt;getSourceProperty($debug_property);<br>      if (is_array($field)) {<br>        $field = var_export($field);<br>      }</pre><pre><em>      // Only show output if run from command line.<br>      </em><strong>if </strong>(PHP_SAPI === <strong>&#39;cli&#39;</strong>) {<br>         Drush::output()-&gt;writeln(dt($field));<br>      } <br>    }<br>  }</pre><p>This little piece of code prints the value of the source property defined in $settings[&#39;test_migrate_debug_source_field&#39;] to the shell when running the Drush command. With this it is easy to find the content that was updated in the Drupal admin. And because it is a setting it is also easy to define a logical source value for any migration.</p><p>To output the debug information we use a function from Drush and to make sure we are running the migration with Drush, and not via the Migrate UI, we wrap the function call in an if-statement which checks if PHP is run from the cli, see the remark about <a href="https://www.drupal.org/node/2295037"><em>drupal_cli</em></a><em> </em>on drupal.org<em>.</em></p><h3>Debugging a migration</h3><p>When using PHPStorm, debugging Drupal code is made extremely easy with the so called ‘Zero-configuration debugging’. But using Drush in a ddev-environment adds some extra layers which make additional configuration necessary.</p><p>The first problem was that when running Drush PHPStorm needs the server name and that this was not added automatically. It can be added by adding the ‘PHP_IDE_CONFIG’ variable to .ddev/docker-compose.environment.yaml</p><pre># Ddev environment variables.<br>​<br>version: &#39;3.6&#39;<br>​<br>services:<br>  web:<br>    environment:<br>      - DRUSH_OPTIONS_URI=$DDEV_PRIMARY_URL<br>      - PHP_IDE_CONFIG=serverName=&lt;local url&gt;</pre><p>Where &lt;local url&gt; should be replace by the url on which your local development site can be reached.</p><p>Running the Drush command from within the ddev-container proved much more reliable than running it from the host.</p><pre>$ ddev ssh<br>$ cd sites/dev/<br>$ /var/www/html/vendor/bin/drush mim my_migration_id --update</pre><p>This assumes you have installed a local version of Drush with composer require drush/drush but this is generally a good idea, especially when the site is not hosted on your own servers and you have little or no influence on the software installed on the server.</p><p>If you use debugging for the first time in a project PHPStorm will ask you for the mapping of the Drush executable. Simply add the local path.</p><h3>Some examples</h3><h4>Body to paragraph</h4><p>In most migrations we implement at LimoenGroen we have a number of default actions. One of this is migrating all or a part of the original body text of a Drupal 7 site to a paragraph in the new Drupal 8 site.</p><p>This is a two step process, first we create the paragraphs with a migration defined as</p><pre>langcode: nl<br>status: true<br>dependencies: {  }<br>id: test_d7_paragraphs_news_item<br>class: Drupal\node\Plugin\migrate\D7NodeTranslation<br>field_plugin_method: null<br>cck_plugin_method: null<br>migration_tags:<br>  - &#39;Drupal 7&#39;<br>  - Content<br>migration_group: test_drupal_7<br>label: &#39;Node News item body -&gt; News paragraph&#39;<br>source:<br>  plugin: d7_node_complete_test<br>  node_type: news_item<br>process:<br>  field_text:<br>    plugin: sub_process<br>    source: body<br>    process:<br>      value:<br>        plugin: remove_media_tags<br>        source: value<br>      format:<br>        plugin: default_value<br>        default_value: filtered_html<br>destination:<br>  plugin: &#39;entity_reference_revisions:paragraph&#39;<br>  default_bundle: text<br>migration_dependencies: null</pre><p>First of all we use our extended source plugin d7_node_complete_test. We also use a processor to remove all embedded media, which is rather specific for this case but shows the usage of such a plugin.</p><p>In the destination section we set the default bundle to our custom paragraph type text which has a rich text field field_text which is filled in the process.</p><p>The next step is to add the created paragraphs to the nodes we have imported. The (partial) configuration for this:</p><pre>langcode: nl<br>status: true<br>dependencies: {  }<br>id: test_d7_node_complete_news_item<br>class: Drupal\node\Plugin\migrate\D7NodeTranslation<br>field_plugin_method: null<br>cck_plugin_method: null<br>migration_tags:<br>  - &#39;Drupal 7&#39;<br>  - Content<br>migration_group: test_drupal_7<br>label: &#39;Node complete (News item -&gt; News)&#39;<br>source:<br>  plugin: d7_node_complete_fwo<br>  node_type: news_item<br>process:<br>  (...)<br>  text_paragraph:<br>    plugin: migration_lookup<br>    migration: test_d7_paragraphs_news_item<br>    source: nid<br>  field_paragraphs:<br>    plugin: sub_process<br>    source:<br>      - &#39;@text_paragraph&#39;<br>    process:<br>      target_id: &#39;0&#39;<br>      target_revision_id: &#39;1&#39;<br>destination:<br>  plugin: &#39;entity_complete:node&#39;<br>  translations: true<br>  default_bundle: article<br>migration_dependencies:<br>  required: <br>    - test_d7_paragraphs_news_item<br>  optional: {}</pre><p>What happens here is that first we look up the paragraph created in the migration with the id test_d7_paragraphs_news_item with the migration_lookup plugin and store this in a pseudo-field.</p><p>Next we add this paragraph to the correct field (in our case the field field_paragraphs). In the process-section of this field we also set the target_id and the target_revision_id which are internal fields on which the entity revision entities depends.</p><h4>A list of links</h4><p>To migrate a multi-value field of links from a Drupal 7 site use the following snippet</p><pre>field_links:<br>    plugin: sub_process<br>    source: field_links<br>    process:<br>      uri: url<br>      title: title<br>      options: attributes</pre><p>In which the name of the Drupal 7 field is the same as the name of the Drupal 8 field, field_links. Note the small but important difference between the Drupal 7 url and the Drupal 8 uri values.</p><h4>Language of the node</h4><p>The above examples were taken from sites in which two languages were defined (English and Dutch), but only Dutch was used.</p><p>So it seemed safe to assume that we could simply use the source language from the Drupal 7 node as target language for the Drupal 8 site. At first it looked like this worked fine, until we examined a number of nodes that were previously imported from a Drupal 6 site (yes, the sites have a long Drupal history…).</p><p>These nodes did not have language ‘nl’ but ‘und’ which led to a number of problems in the Drupal 8 site with respect to translations and automatic URL aliases. The solution was simple, in the process section</p><pre>langcode:<br>    -<br>      plugin: default_value<br>      source: language<br>      default_value: nl</pre><h3>Conclusion</h3><p>Migrations will always be hard, despite all the effort the Drupal community has put in to the migrate classes. So debugging migrations will continue to be a necessary skill, maybe this article will help you to get the job done.</p><h3>Links</h3><p><a href="https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html">PHPStorm zero-configuration debugging</a></p><p><a href="https://www.drupal.org/docs/core-modules-and-themes/core-modules/migrate-module">Migrate in Drupal core</a></p><p><a href="https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins">Migrate process plugins</a></p><p><a href="https://ddev.readthedocs.io/en/stable/">DDEV</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=794bb9800546" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/drupal-migrations-in-ddev-794bb9800546">Drupal Migrations in ddev</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Mensen met een beperking gebruiken mijn website niet”]]></title>
            <link>https://medium.com/limoengroen/mensen-met-een-beperking-gebruiken-mijn-website-niet-f087e5b1e37a?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/f087e5b1e37a</guid>
            <category><![CDATA[a11y]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[toegankelijkheid]]></category>
            <category><![CDATA[web-accessibility]]></category>
            <dc:creator><![CDATA[Marloes Bosch]]></dc:creator>
            <pubDate>Thu, 10 Mar 2022 13:37:23 GMT</pubDate>
            <atom:updated>2022-03-10T13:37:23.743Z</atom:updated>
            <content:encoded><![CDATA[<p>“Mijn website hoeft niet toegankelijk te zijn, want mensen met een beperking gebruiken mijn website niet.” Een veelgehoorde misvatting en ook één waar mijn nekharen van overeind gaan staan. Hoezo gebruiken “mensen met een beperking” jouw website niet? Als een restaurant ontoegankelijk is, kiest een rolstoelgebruiker bij voorbaat toch een ander restaurant om naartoe te gaan? Eentje die wel rolstoelvriendelijk is? Dat geldt ook voor websites. Als je website ontoegankelijk is voor mensen met een beperking, is het toch ook logisch dat ze je website niet naar wens kunnen gebruiken? Een incorrecte oorzaak — gevolg relatie als je het mij vraagt. Sowieso, wat wordt er bedoeld met “mensen met een beperking”. Het impliceert dat het een heel klein uniform groepje is, dat toch niet meetelt. Dat is zeker niet het geval, want het gaat om veel meer mensen dan je denkt.</p><h3>De cijfers liegen er niet om</h3><p>Stel nou dat je een nieuwe website laat maken, maar niemand in Amsterdam, Rotterdam en Den Haag kan er gebruik van maken. Dat zijn iets meer dan twee miljoen mensen die bij voorbaat jouw online platform niet kunnen bezoeken. Het zou toch heel vreemd zijn wanneer je website in al die grote steden niet bruikbaar is. Hoe zouden de stakeholders reageren? Zou die website dan gelanceerd worden? Lijkt me niet. Al die bezoekers die je dan misloopt…</p><p>Laat Nederland nu ook ongeveer <a href="https://www.rijksoverheid.nl/onderwerpen/rechten-van-mensen-met-een-handicap">twee miljoen mensen</a> met een beperking tellen. Grofweg alle inwoners van Amsterdam, Rotterdam en Den Haag bij elkaar. Ja, die sluit je buiten wanneer jouw website niet toegankelijk is. Weet je zeker dat er geen potentiële bezoekers vallen onder die twee miljoen mensen met een beperking? Dus waarom is het dan wel oké om een ontoegankelijke website te lanceren?</p><h3>Nog even over die cijfers…</h3><p>Die twee miljoen is een schatting. Het exacte aantal mensen met een beperking is heel lastig vast te stellen. Er is een breed scala aan beperkingen waaronder: motorische, organische, zintuiglijke, verstandelijk en psychosociale beperkingen. Sommige mensen hebben een meervoudige beperking. Telt dat dan dubbel? Een beperking is niet altijd zichtbaar. Wordt dat dan wel meegeteld? Niet iedereen ervaart een beperking als een beperking. Hoe reken je dat mee? En daarnaast, welke definitie hanteren we voor een “beperking”? Het is duidelijk, de berekening is niet eenduidig. Het cijfer voor het aantal beperkte mensen ligt daarom in de praktijk een stuk hoger dan de twee miljoen die bekend is bij de Rijksoverheid.</p><h3>Vergeet de cijfers</h3><p>Sterker nog, iedereen ervaart in het leven een keer een vorm van een beperking. Niet alle beperkingen zijn aangeboren of chronisch en daardoor geregistreerd onder de noemer “mensen met een beperking”.</p><h4>Tijdelijke beperking</h4><p>Het zou zomaar kunnen dat je straks een rondje buiten gaat wandelen en dat je struikelt over het stoeprandje. Rechterarm gebroken en in het gips. Laat dat nou net je muisarm zijn! De muis bedienen met je linkerhand voelt heel raar, want dat ben je natuurlijk niet gewend. Mikken op dat kleine menu knopje bovenin het scherm is ineens toch een stuk lastiger. Na een maandje mag het gips er waarschijnlijk wel af, maar tot die tijd kun je je rechterarm niet gebruiken zoals gewoonlijk. Je bent dan tijdelijk beperkt.</p><h4>Situationele beperking</h4><p>Zelfs in kortere periodes kun je een beperking ervaren. Een korte momentopname, een situatie. Je zit op het balkon en je wilt een lekkere Italiaanse pizza bestellen, maar de zon schijnt zo fel dat je niet goed kunt lezen wat er op je mobiele scherm staat. Je moet toch echt naar binnen om het menu te kunnen lezen en de order te kunnen versturen. Balen, je zit net zo lekker. Je bestelt wel bij de concurrent waar je het menu wel kunt lezen. Was nu het contrast van de website maar hoger.</p><p>Zo zijn er ongetwijfeld meer situaties waarop je op het moment zelf niet beseft dat je beperkt bent. Wat dacht je van een YouTube video zonder ondertiteling en je bekijkt die, terwijl je in een luidruchtige ruimte staat. Je kunt het niet verstaan. Of de website die niet wil laden, omdat je 5G op dat moment net even wat minder is. De informatie die je nodig hebt, krijg je niet tot je beschikking. Los van de ernst van de situatie, je bent dan dus ook even beperkt.</p><h4>Ouderdom</h4><p>Een niet te onderschatten vorm van beperking is dat we allemaal een dagje ouder worden. Tenminste, dat hoop ik dan maar. En bij ouder worden komen er soms steeds meer kwaaltjes om de hoek kijken. Grote kans dat je slechter gaat zien of je gaat slechter horen. Dan is het toch wel fijn als de tekst op een website goed leesbaar is en de video’s ondertiteling hebben.</p><h3>Niet optioneel</h3><p>Je kunt er niet bij voorbaat vanuit gaan dat mensen met een beperking je website niet gebruiken. Die groep “mensen met een beperking” is veel diverser, dynamischer en groter dan je in eerste instantie zou denken. Het exacte aantal valt niet te berekenen. Natuurlijk willen mensen met een beperking je online platform ook gebruiken als die voor hen relevant is. Maar als je website ontoegankelijk is, worden zij daarin beperkt. De ironie. De beperking ligt niet bij de groep “mensen met een beperking”, maar bij hen die een toegankelijke website niet als eis zien, maar als optioneel. Iedereen profiteert van een toegankelijke website. Het verhoogt de gebruiksvriendelijkheid voor verschillende mensen (waaronder jij en ik) en in verschillende situaties. Dus ja, je website dient wel toegankelijk te zijn.</p><h3>Toegankelijkheidsexperts</h3><p>Marloes Bosch is front-end specialist en expert op het gebied van accessibility bij LimoenGroen. LimoenGroen deelt veel kennis op het gebied van digitoegankelijkheid, op congressen en online magazines, waaronder Emerce en <a href="https://www.marketingfacts.nl/berichten/waarom-digitale-toegankelijkheid-iedereen-gaat-raken">Marketingfacts</a>. Onze medewerkers zijn gecertificeerd door <a href="https://accessibility.nl/">Stichting Accessibility</a>, de autoriteit in Nederland op het gebied van digitale toegankelijkheid. Wil je weten hoe de digitale toegankelijkheid van jouw website kan worden verbeterd? Stuur een bericht en we praten je graag vrijblijvend bij. Je kunt Marloes mailen op <a href="/service/mailto:marloes@limoengroen.nl">marloes@limoengroen.nl</a>.</p><figure><img alt="Een opengeklapte laptop met een aangesloten Braille toetsenbord." src="https://cdn-images-1.medium.com/max/1024/1*dyTMsdqGdd3wSd6laEwDbQ.jpeg" /><figcaption>Foto van <a href="https://unsplash.com/@elizabeth_woolner">Elizabeth Woolner</a> op <a href="https://unsplash.com/photos/9xxNZCJZ8bA">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f087e5b1e37a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/mensen-met-een-beperking-gebruiken-mijn-website-niet-f087e5b1e37a">“Mensen met een beperking gebruiken mijn website niet”</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drupal caching debugging part 1: Caching layers]]></title>
            <link>https://medium.com/limoengroen/drupal-caching-debugging-part-1-caching-layers-e5c85b8338e8?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/e5c85b8338e8</guid>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[varnish-cache]]></category>
            <category><![CDATA[varnish]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[drupal-8]]></category>
            <dc:creator><![CDATA[Louis Nagtegaal]]></dc:creator>
            <pubDate>Thu, 06 May 2021 09:03:55 GMT</pubDate>
            <atom:updated>2021-05-06T09:20:27.304Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sH4w0jJ8kUf4xzmN0WHaaA.jpeg" /></figure><p>When it comes to caching, sooner or later (like some variant of <a href="https://en.wikipedia.org/wiki/Godwin%27s_law">Godwin’s law</a> ) someone will refer to Phil Karltons paradigm:</p><blockquote><em>There are only two hard things in Computer Science: cache invalidation and naming things.</em></blockquote><p>Since Drupal 8 there is an elaborate caching system, I would say that with respect to caching there are two hard questions:</p><ol><li>How do I make sure my data is cached?</li><li>How do I make sure my data is <em>not</em> cached?</li></ol><p>In most cases Drupal will handle the first issue for us. For anonymous users most of the pages will be cached, as we will see in more detail in the section about caching layers. The second issue is more or less caused by the first: if in our setup most data comes from cache for anonymous users, how do we make exclude the parts we do not want to be cached?</p><p>But most of all, if cache invalidation is such a hard thing, we must have some way to determine if we have a caching problem. In Drupal, solving the problem is in most of the cases not such a hard thing. Recognizing a problem is a lot harder.</p><p>Debugging caching problems is a very broad subject and won’t fit in a single blogpost. So in this one I will concentrate on the different layers of caching.</p><h3>The different layers of caching</h3><p>Visiting a website is a process that involves a large number of applications, each of which can (and usually does) cache data. The important question is if a layer causes caching bugs and if so, if we can somehow influence the behaviour of the layer. Let’s take a look at each layer, starting at the layers where it all starts, (or, for the less customer oriented developer, ends): the browser.</p><h4>Browser cache</h4><p>With all the caching layers that will follow, browser cache almost seems something from the days of 2400 baud modems. But even now not everyone has broadband internet, and even if people have it at home, they won’t have it while underway. And more importantly, the default operation modus of browser is to cache the data they receive so we must deal with this caching in some way.</p><p>To control this cache layer we can use the <em>Cache-Control</em> HTTP header. The most useful is the ‘max-age’ directive that defines the maximum amount of time in seconds that responses are allowed to be used again. A value of <em>max-age=0</em> indicates that the cache entry requires re-validation.</p><p>To prevent caching completely the ‘no-cache’-directive seems a likely candidate but ‘no-cache’ does not mean <em>do not cache at all</em>. It means ‘revalidate with server’ before using any cached response the browser may have, on every request. So if any of the other layers indicates the cache data is not stale, the browser will use it.</p><h4>Let go or dive in?</h4><p>Apart from setting the max-age parameter</p><pre>$config[&#39;system.performance&#39;][&#39;cache&#39;][&#39;page&#39;][&#39;max_age&#39;] = &lt;time in seconds&gt;;</pre><p>there is not much you can do here and, most likely, the problem you try to solve does not originate in this layer but one of the following.</p><h4>Reverse proxy</h4><p>If we disregard any caching by smart routers or proxies in (corporate) networks, the reverse proxy is the next caching layer we are most likely to encounter. Of the reverse proxies <em>Varnish</em> is one of the most used. In the test setup discussed in a later part of this series, we will use DDEV with a <em>Varnish</em> container to test, but the same principles will apply to any other reverse proxies.</p><p>For Drupal the purge-module (<a href="https://www.drupal.org/project/purge">https://www.drupal.org/project/purge</a>) is a generic and (as the project page states) <em>modular external cache invalidation framework</em> suitable for any reverse proxy. For <em>Varnish</em> it should be used in combination with the purge_purger_http-module, see <a href="https://www.jeffgeerling.com/blog/2016/use-drupal-8-cache-tags-varnish-and-purge">Use Drupal 8 Cache Tags with Varnish and Purge</a> for a good introduction by Jeff Geerling.</p><h4>Let go or dive in?</h4><p>Unless you are setting up a new server, or are really suspicious about your sysop, it is not very likely that the problem you are trying to solve stems from the <em>Varnish</em> configuration.</p><p>Some knowledge of the <em>Varnish</em>-tools, like varnishlog and varnishadm can help to find the deeper problem, but I would not recommend to let yourself be drawn into the world of vcl&#39;s and <em>Varnish</em>-debugging, unless of course you are looking for a new, time -consuming late-night hobby.</p><p><a href="https://info.varnish-software.com/blog/how-to-debug-and-fix-varnish">DON&#39;T BUG ME: HOW TO DEBUG AND FIX VARNISH</a> gives a very basic starter on debugging <em>Varnish</em>, and recommends coffee while doing so. <a href="https://varnish-cache.org/docs/6.5/users-guide/increasing-your-hitrate.html">Achieving a high hitrate</a> is a more elaborate introduction, but however does not recommend coffee.</p><h3>Opcode cache</h3><p>Since we are discussing Drupal and Drupal is a PHP/Symfony application, using an opcode cache will improve your site performance, but it will not be the killer app that solves al your problems. On the other hand, the way these work and the fact that they have become so stable, make it very unlikely that they are the source of the problem.</p><h4>Let go or dive in?</h4><p>Like with <em>Varnish,</em> most of the time you can trust your sysop and take these for granted. If you <em>are</em> looking for a new hobby though, <em>Varnish </em>is much more fun.</p><h4>Application cache</h4><p>The caching in the application, in our case Drupal, is at the base of good performance. Of course all the layers mentioned above are important, and I really do not recommend running any serious site without them, but the application caching layer is the most relevant because for us, Drupal developers. And it is the layer in which we can make a real difference.</p><p>But it also means we have to accept that the fault is on our side, and not with the sysop or hosting company (or the customer who has employed them). I personally really find life much easier to start with accepting this, and only point to the other (p)layers when I have solid proof the fault lays there.</p><h4>Let go or dive in?</h4><p>Dive! Dive! Dive! Its not only fun, it will also make your site better.</p><h4>Drupal Internal Page Cache</h4><p>The <em>Internal Page Cache-</em>module implements caching for anonymous users. The code for this module can be found at core/modules/page_cache and since it is very well documented (the comments almost exceed the actual code) it is a good starting point if you want to learn more about this cache layer.</p><p>If you look at it you will find the code is very compact, the main reason for this is of course that it uses an implementation of Drupal\Core\Cache\CacheBackendInterface to do the actual work. The logic about when to store or retrieve the cached data however is implemented in the Drupal\page_cache\StackMiddleware\PageCache-class.</p><p>The module defines two services but don&#39;t be tempted to use these directly, in almost all cases using cache-tags and -contexts, provided by the <em>Internal Dynamic Page Cache</em>, is a far cleaner and better solution.</p><h4>Drupal Internal Dynamic Page Cache</h4><p>The <em>Internal Dynamic Page Cache</em>, found in core/modules/dynamic_page_cache, is a smarter caching implementation and also caches data for authenticated user, or, as the module page on Drupal.org states:</p><blockquote><em>It caches pages minus the personalized parts, and is therefore useful for </em>all<em> users (both anonymous &amp; authenticated).</em></blockquote><p>This cache implements, unlike the <em>Internal Page Cache</em>, the EventSubscriberInterface because &quot;(...)many cache contexts can only be evaluated after routing&quot;.</p><p>Although the <em>Internal Page Cache</em> is an excellent way to improve performance in a zero-configuration way (okay, there is one setting on /admin/config/development/performance) for anonymous users, the real power comes with the implementation of cache-tags and cache-context.</p><p>And, as always, with real power come real problems.</p><h4>Drupal Render cache</h4><p>Since Drupal 8 Drupal has a smart rendering system that caches (parts of) render arrays and ensures not all HTML is rendered every time, and, more importantly <em>is</em> rendered new when involved content is changed.</p><p>The render cache is implemented in:</p><pre>core/lib/Drupal/Core/Render/RenderCache.php</pre><p>This file contains large stretches of comments, especially in the ‘set’-function, absolute worthwhile a read.</p><p>In the debugging part of this serie we will go into more details of the render cache. For now it is good to know that to each render array cache-tags and -context can be added and that this provides a fine-grained caching.</p><h3>Drupal cache backends</h3><p>In Drupal core a number of cache backends are implemented:</p><ul><li><em>\Drupal\Core\Cache\ApcuBackend</em><br>implemented in <em>\Core\Cache\Apcu4Backend</em></li><li><em>\Core\Cache\MemoryBackend</em> implemented in <em>\Drupal\Core\Cache\MemoryCounterBackend</em> and <em>\Drupal\Core\Cache\MemoryCacheMemoryCache</em></li><li><em>\Drupal\Core\Cache\PhpBackend</em></li><li><em>\Drupal\Core\Cache\DatabaseBackend</em></li></ul><p>The last one, DatabaseBackend, is Drupal&#39;s default cache implementation. In special cases you can use one of the other implementations, or use a module, like the<a href="https://www.drupal.org/project/redis"> Redis-module</a>, to get even more implementations.</p><p>Besides the implementations mentioned above there are a number of special implementations:</p><ul><li><em>\Drupal\Core\Update\UpdateBackend<br></em>This is a special implementation for use during Drupal database updates.</li><li><em>\Drupal\Core\Cache\BackendChain</em><br>This implementation makes it possible to combine two different backends, for example a really fast one with limited resources (like <em>MemoryBackend</em>) and a slower one (like <em>DatabaseBackend</em>), which is addressed when the cached item is not found in the first one.</li><li><em>\Drupal\Core\Cache\ChainedFastBackend <br></em>The <em>ChainedFastBackend</em> is a special implementation of the <em>BackendChain</em>, especially suited for website runnnig on multiple nodes. While <em>BackendChain </em>works on the assumption that both backends are consistent, <em>ChainedFastBackend </em>does not assume the fast-backend is consistent (that is, in sync with all nodes). <br>To check if it can serve the items from the fast cache, it keeps track of the last time items were written to the slower, consistent backend and only serve the items from the fast backend if they were created before this timestamp.</li><li><em>\Drupal\Core\Cache\NullBackend </em>The most common use case for this backend is during development. Because clearing the cache after each change is time consuming most Drupal developers enable this backend in the local settings:</li></ul><pre>$settings[&#39;container_yamls&#39;][] = &#39;../settings/services.local.yml&#39;;<br>$settings[&#39;cache&#39;][&#39;bins&#39;][&#39;render&#39;] = &#39;cache.backend.null&#39;;<br>$settings[&#39;cache&#39;][&#39;bins&#39;][&#39;page&#39;] = &#39;cache.backend.null&#39;;<br>$settings[&#39;cache&#39;][&#39;bins&#39;][&#39;dynamic_page_cache&#39;] = &#39;cache.backend.null&#39;;</pre><p>The services.local.yml is necessary to define the cache.backend.null services, like this:</p><pre>services:<br>  cache.backend.null:<br>    class: Drupal\Core\Cache\NullBackendFactory</pre><p>And can als be used to enable a number of other useful debugging functions, like twig-debugging and sending headers to debug the cacheability of pages.</p><h4>Pitfall number one</h4><p>The <em>NullBackend </em>implementation makes development a lot smoother, but, as you probably can see, is also a very large pitfall. Code that (seems) to be working perfectly on the local development environment or maybe even on the test server, can produce unexpected and unwanted behaviour that will be hard to debug, especially if this must be done after some time.</p><p>Even the most concise customer or tester will not always be aware of caching problems or how to test them. And in most cases this will even be a larger problem if someone other than the developer who has written the code has to debug it later on. Maybe this develop will profit from the next part of this series: <em>Debugging caching.</em></p><p>Louis Nagtegaal is all round digital specialist at <a href="https://limoengroen.nl/">LimoenGroen</a> with a strong focus on back-end development. LimoenGroen (Dutch for ‘lime green’) is a team of passionate people working with Drupal for a broad range of clients. We provide user-centric, scalable websites and digital solutions that will add lasting value to organizations. With a strong focus on web accessibility and open source, we care to share. We are based in Amsterdam, The Netherlands. We have worked for many top Dutch and international brands including <a href="https://www.limoengroen.nl/project/iucn-website-wordt-gebruiksvriendelijk-en-efficient">IUCN</a>, <a href="https://www.limoengroen.nl/project/24kitchennl">Fox</a> and <a href="https://www.limoengroen.nl/project/van-gogh-worldwide">Van Gogh Museum</a>. Would you like to know more about meta tags, accessibility or web development? Contact Louis at louis@limoengroen.nl.</p><p>Photo by <a href="https://unsplash.com/@floriankrumm?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Florian Krumm</a> on <a href="https://unsplash.com/s/photos/servers?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5c85b8338e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/drupal-caching-debugging-part-1-caching-layers-e5c85b8338e8">Drupal caching debugging part 1: Caching layers</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop loneliness, a story about meta tags in Drupal]]></title>
            <link>https://medium.com/limoengroen/stop-loneliness-8b0b057b0392?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/8b0b057b0392</guid>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[open-graph]]></category>
            <category><![CDATA[meta-tags]]></category>
            <category><![CDATA[drupal]]></category>
            <dc:creator><![CDATA[Louis Nagtegaal]]></dc:creator>
            <pubDate>Thu, 24 Sep 2020 06:40:13 GMT</pubDate>
            <atom:updated>2020-09-24T08:35:38.430Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stop loneliness — a story about meta tags in Drupal</h3><p><strong>In a way the work of a web developer is not unlike that of a midwife, when our work is done the subject (the child or the website) is just at the beginning of its life. And, like a midwife, we also hope that our brand new site will grow up to be successful, with a lot of sensible, useful content and of course lots of friends or, in our case, visitors. And of course the content is what really makes a website and although we have little or no influence on the content, we can do a lot to make sure that the content is found by the right persons. One way to do this is by supplying search engines and social media platforms with the correct data about our site by means of meta tags. Here’s how you do this properly in Drupal.</strong></p><p>In this blog I will discuss a number of things. First I will give you a number of reasons why you should implement meta tags. Then I will give a short overview of the most important kinds of meta tags and I will give a short overview of the use of meta tags in Drupal.</p><p>A large part will be dedicated to how to set up meta tags Drupal and I will end with how to test the meta tags for your website.</p><figure><img alt="Screen with website and corresponding source code" src="https://cdn-images-1.medium.com/max/1024/1*ROaVyhVWwlQC-hVXuo7FFg.jpeg" /></figure><h3>Why use meta tags</h3><p>So why would you spent time setting up meta tags. Of course it will help your site to be found, but there are also some other advantages.</p><p>For one, setting up the meta tags will give you full control over the images used on social media and in search results. If the image used in the article is shown it will be a lot more attractive to users to follow the link compared to showing just some random image from your site. This is for example how Facebook and Twitter show some recipes I shared:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uIVWIg8Mw1Sb3lmi3xsoWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aVHgNxQ1I43ql7w-v-PbmQ.png" /></figure><p>Because in Drupal it is possible to select a specific image style to be used in the different meta tags, you also can control how the image will be cropped. I will go into this in more detail when discussing how to set up meta tags in Drupal.</p><p>Schema.org, implemented by Google, Microsoft Bing, Yahoo and Yandex has an extra advantage: because of its roots in semantic web initiatives, it has a hierarchy of objects with specific properties that can be used by search engines to do more with the search result. A good example of this is the “how to”-type. If I search for ‘drupal 8 upgrade to 9’ in Google it will not only show websites with content about Drupal 8 and 9, it will also show some of the steps necessary to perform the upgrade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yThp4ExzEA7IV4InuhTdjQ.png" /></figure><p>Another good example is the “Recipe”-type (which is a subclass of the “How to”-type). If I search in Google for “risotto Jamie Oliver” the first result will not only point me to a website with this recipe, it will also show the ingredients necessary for this recipe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ThCJPOw5dSMghG2Cam2kDw.png" /></figure><p>Although it is hard to predict when Google will show the recipe and when not, in cases it does it certainly will attract extra traffic to your site.</p><p>The list of available types can be viewed at</p><p>https://developers.google.com/search/docs/data-types/article</p><h3>Types of meta tags</h3><p>The internet is a still evolving environment and although al lot is done to set standards for every part of the web, in some cases, like in the case of meta tags, this resulted in a (large) number of standards. I will discuss not all of them, but take a selection bases on the question of making your website less lonely, and yes, that means social media are involved.</p><h3>HTML</h3><p>The oldest type are the basic tags in HTML. In HTML there are a number of default meta tags that are added by Drupal:</p><pre>&lt;meta name=&quot;title&quot; content=&quot;Page Title | Website name&quot; /&gt;<br>&lt;meta name=&quot;Generator&quot; content=&quot;Drupal 8 (https://www.drupal.org)&quot; /&gt;<br>&lt;meta name=&quot;MobileOptimized&quot; content=&quot;width&quot; /&gt;<br>&lt;meta name=&quot;HandheldFriendly&quot; content=&quot;true&quot; /&gt;<br>&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;<br>&lt;meta name=&quot;description&quot; content=&quot;Learn more about meta tags.&quot; /&gt;</pre><p>The effectivity of the proprietary tags ‘MobileOptimized’ and ‘HandheldFriendly’ is a point of discussion, see the links at the end of this article.</p><p>These tags were declared dead more than once, but since we get them for free from Drupal and because the description tag can be used by search engines as primary description for your website it still is a good idea to use them.</p><h3>Open Graph</h3><p>The Open Graph meta tags are used by, among others, Facebook, Pinterest and LinkedIn. According to the (apparently out of date) <a href="https://opg.me/">https://opg.me</a>-website</p><blockquote><em>The </em><a href="https://ogp.me/"><em>Open Graph protocol</em></a><em> 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.</em></blockquote><p>In the page source you can recognise the Open Graph tags by the ‘og-’ prefix of the property, for example:</p><pre>&lt;meta property=&quot;og:site_name&quot; content=&quot;Lekkertoegankelijk&quot; /&gt;<br>&lt;meta property=&quot;og:type&quot; content=&quot;article&quot; /&gt;<br>&lt;meta property=&quot;og:url&quot; content=&quot;https://lekkertoegankelijk.nl/blog/stop-loneliness&quot; /&gt;<br>&lt;meta property=&quot;og:title&quot; content=&quot;Stop Loneliness&quot; /&gt;</pre><p>The meta tags-module also has a ‘Facebook’-submodule. This is a</p><blockquote><em>A set of meta tags specially for controlling advanced functionality with </em><a href="https://www.facebook.com/"><em>Facebook</em></a><em>.</em></blockquote><p>and is not a replacement for the Open Graph tags. Unless you have specific requirements you can leave the fields in the ‘Facebook’-section empty, but for a correct display of your site when the URL is shared on Facebook setting up the Open Graph meta tags is essential.</p><h3>Twitter cards</h3><p>The documentation from Twitter states:</p><blockquote><em>With Twitter Cards, you can attach rich photos, videos and media experiences to Tweets, helping to drive traffic to your website.</em></blockquote><p>So exactly what we are looking for! In the page source you can recognise the Twitter card tags by the ‘twitter’-prefix of the name, for example:</p><pre>&lt;meta name=&quot;twitter:card&quot; content=&quot;summary&quot; /&gt;<br>&lt;meta name=&quot;twitter:title&quot; content=&quot;Stop Loneliness&quot; /&gt;<br>&lt;meta name=&quot;twitter:description&quot; content=&quot;Learn more about meta tags.&quot; /&gt;<br>&lt;meta name=&quot;twitter:url&quot; content=&quot;https://lekkertoegankelijk.nl/blog/stop-loneliness&quot; /&gt;</pre><h3>Schema.org</h3><p>As stated above, the schema.org tags are not part of the meta tags module. To use them you have to get the module</p><p><em>&gt; composer require drupal/schema_metatag</em></p><p>and then at minimum enable the modules</p><ul><li>Schema.org Metatag</li><li>Schema.org Article</li></ul><p>Schema.org does not use the default tags but uses the <em>ld+json</em>-format, for example:</p><pre>&lt;script type=&quot;application/ld+json&quot;&gt;{<br> &quot;@context&quot;: &quot;https://schema.org&quot;,<br> &quot;@graph&quot;: [<br>  {<br>   &quot;@type&quot;: &quot;Article&quot;,<br>   &quot;headline&quot;: &quot;Stop Loneliness&quot;,<br>   &quot;name&quot;: &quot;Stop Loneliness&quot;,<br>   &quot;description&quot;: &quot;Learn more about meta tags.&quot;,<br>   &quot;isAccessibleForFree&quot;: &quot;True&quot;,<br>   &quot;author&quot;: {<br>     &quot;@type&quot;: &quot;Organization&quot;,<br>     &quot;@id&quot;: &quot;https://lekkertoegankelijk.nl&quot;,<br>     &quot;name&quot;: &quot;Lekkertoegankelijk&quot;,<br>     &quot;url&quot;: &quot;https://lekkertoegankelijk.ddev.site/&quot;<br>   },<br>   &quot;publisher&quot;: {<br>     &quot;@type&quot;: &quot;Organization&quot;,<br>     &quot;name&quot;: &quot;Lekkertoegankelijk @ Limoengroen&quot;,<br>     &quot;url&quot;: &quot;https://lekkertoegankelijk.ddev.site/&quot;<br>   },<br>   &quot;mainEntityOfPage&quot;: &quot;https://lekkertoegankelijk.ddev.site/blog/stop-loneliness&quot;<br>   }<br> ]<br>}&lt;/script&gt;</pre><p>The list of possible objects in schema.org is huge, see</p><p><a href="https://schema.org/docs/full.html">https://schema.org/docs</a>.</p><p>For an overview of the objects implemented in the Drupal module see the Drupal project page at</p><p><a href="https://www.drupal.org/project/schema_metatag">https://www.drupal.org/project/schema_metatag</a></p><h3>Meta tags in Drupal</h3><p>De Drupal meta tags module (<a href="https://www.drupal.org/project/metatag">https://www.drupal.org/project/metatag</a>) is used by over 400,000 sites (statistics of august 2020) and comes with a (still growing) set of sub-modules which make it easy to supply meta tags for a large number of social media platforms and support for, for example, the views-module. The module supports among others:</p><ul><li>Dublin core</li><li>Facebook</li><li>Twittercards</li><li>Google Plus</li></ul><p>If you include the separate <em>Schema meta tag </em>module you will have covered the most important meta tags.</p><h3>Metatags UI</h3><p>The default use case of the meta tags module is one in which all meta tags are set (via tokens) in the admin UI on ‘/admin/config/search/metatag’, which we will discuss later on.</p><p>There is however also the possibility to allow content editors to fill in the meta tags. This is done by adding a field of the type ‘Metatags’ to the content type and add it to the form display. This will work, but by default it will show <em>all</em> possible settings, which can be quite dazzling for a less-experienced editor because, depending on the enabled sub modules, this can be dozens of fields.</p><p>One solution for this would be to add a custom module with a hook_form_node_form_alter and to hide all the fields which we do not want to show to the editor.</p><p>However, in most cases we only want to make a small number of fields, like ‘Description’ or ‘Summary’, available to be overridden by the editor and use the defaults for the rest. In this case a cleaner solution would be to add extra fields to the content type which will only be available in the edit form. In the default settings for meta tags (‘/admin/config/search/metatag’) this field can then be filled in with the correct token.</p><h4>Custom meta tags</h4><p>You can also define your own meta tags, for example if you want custom data for a specific analytics tool.</p><p>Defining a meta tag in a custom module is rather simple because of the Drupal 8 plugin and annotation systems. In your custom module add a class in</p><p>custom_module/src/Plugin/metatag/Tag/CustomMetaTag.php</p><p>With as content</p><pre>namespace Drupal\custom_module\Plugin\metatag\Tag;<br>​<br>use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase;<br>​<br> /**<br> * The custom meta tag.<br> *<br> * @MetatagTag(<br> *   id = &quot;custom_tag_id&quot;,<br> *   label = @Translation(&quot;Custom&quot;),<br> *   description = @Translation(&quot;The custom tag.&quot;),<br> *   name = &quot;custom:thema&quot;,<br> *   group = &quot;custom&quot;,<br> *   weight = 8,<br> *   type = &quot;label&quot;,<br> *   secure = FALSE,<br> *   multiple = FALSE<br> * )<br> */<br>/**<br> * CustomMetaTag.<br> */<br>class CustomMetaTag extends MetaNameBase {<br>​<br>  /**<br>   * {@inheritdoc}<br>   */<br>  public function output() {<br>    (...)<br>  }<br>​<br>}<br>​</pre><p>If you do not define a custom output method, the data from the token of text will be rendered.</p><p>Of course the real magic is in the implementation of the ‘output’-function if you want anything else than plain tokens (see for an example the code in the module code in ‘src/Plugin/metatag/Tag/Keywords.php’), but since there are enough examples in the meta tag module I will not go into this in detail.</p><p>If you do not define a custom output method, the data from the token or text will be rendered.</p><p>This will give you a new type of meta tag that you can edit on the administration pages just like any other meta tag. You can use the same tokens as in other meta tags and of course can also implement your own tokens if you have need for some specialised data.</p><h3>Meta tags settings</h3><p>The settings page for meta tags (/admin/config/search/metatag) is divided in a number of sections. Almost all sections inherit the settings from &#39;Global&#39;, but there are a number of exceptions which are discussed below.</p><h3>Global</h3><p>The settings in ‘Global’ are inherited by most other sections so it would seem to be the (only) place to set the meta tags. But if you check which tokens are available here, you will notice that the tokens for ‘node’ are not present. So yes, this is a important section to set up correct, but most of the ‘real’ work will be done in the ‘Content’-section.</p><h3>Front page</h3><p>The front page is somewhat special. Even if you have a custom node type for the front page, you should set the meta tags here because the settings for that type will not be used when the front page is rendered.</p><p>As an alternative you can use the hook_metatag_route_entity to set the node whose meta tags will be rendered on the front page:</p><pre>/**<br>* Implements hook_metatag_route_entity().<br>*/</pre><pre>function mymodule_metatag_route_entity(RouteMatchInterface $route_match) { <br>  // For which route<br>  if ($route_match-&gt;getRouteName() === &#39;mymodule.front&#39;) {<br>    //Custom service to get our front node.<br>    if ($node = \Drupal::service(&#39;mymodule.helper&#39;)-&gt;getFrontpageNode()) {<br>         return $node;<br>      }<br>   }<br>}</pre><p>In the above code we assume there is a custom route ‘mymodule.front’ and a service ‘mymodule.helper’ with a function ‘getFrontpageNode’ which returns the node we use as front page.</p><p>But in hook_metatag_route_entity you can use any method to get the correct node, even a hard coded node id (although personally I regard setting hard coded node id&#39;s in code as something <strong><em>evil</em>).</strong></p><p>The meta tag module also defines a hook that can be used to alter the meta tags for any given route:</p><pre>/**<br>* Implements hook_metatags_alter().<br>*/</pre><pre>function mymodule_metatags_alter(array &amp;$metatags, array &amp;$context) {<br>   // Exclude meta tags on frontpage.<br>   if (\Drupal::service(&#39;path.matcher&#39;)-&gt;isFrontPage()) {<br>      $metatags = NULL;<br>   }<br>}</pre><h3>403 Access denied &amp; 404 Page not found</h3><p>Default these two items inherit the canonical_url and the shortlink from the settings in &#39;Global&#39;. Is it important that the &#39;Page not found&#39; can be found? The defaults settings will be sufficient in this case.</p><h3>Content</h3><p>As stated above the content section is the section where we will do most of the work. Most of the meta tags should be set here, but if a certain content type (for example a ‘Blog’) has specific settings, you can add these by with the button ‘Add default meta tags’ on ‘/admin/config/search/metatag’.</p><p>of course with this button you will not be adding default meta tags, but add settings for default meta tags for a specific content type. In the use case where editors have the ability to set the meta tags for each content item however, these settings are the defaults they will see in the node add/edit form, hence the description in the button.</p><p>In the content section you will have access to all the node tokens and so this will be the place to talk about a number of specific details.</p><h4>Description</h4><p>For the description fields you may be tempted to use the node:summary-token but please be aware that this token is somewhat special. In the Drupal core code it says:</p><pre>if ($name == &#39;summary&#39;) {<br>   // Generate an optionally trimmed summary of the body field.<br>   // Get the &#39;trim_length&#39; size used for the &#39;teaser&#39; mode, if<br>   // present, or use the default trim_length size.</pre><p>In other words, if you want to set the number of characters shown, you must alter the number of characters shown in the summary of the body field for the ‘Teaser’ view mode for all (or a specific) content type.</p><p>Furthermore the text will be truncated so the editors will have no influence on the text shown. In most cases it will be better to give the editors access to a field to enter the description, and not reuse the summary for this.</p><h4>Dates</h4><p>All dates for Schema.org must be formatted in the ISO 8601 format. A clean solution for this is by adding a date time format for this <strong>Format string </strong>‘c’. If the machine name for this is ‘iso_8601’ you kan use it with a token in the following way:</p><pre>[node:changed:iso8601]</pre><p>Even if you have an existing date time format adding one specific for ISO 8601 wil prevent errors when the date format is changed because for usage on other places.</p><h4>Images</h4><p>If an image is added, for example for the OpenGraph ‘Image’-tag, make sure you use a correct image style to limit the size of the image.</p><p>If for example, if the field that references a media item with an image is called ‘field_image’, the media item uses the field ‘field_media_image’ to store the image and the image crop we want tos use has the (machine) name ‘metatag_image’ then the value in the OpenGrap image field would be</p><pre>[node:field_image:entity:field_media_image:metatag_image]</pre><p>And for the dimensions of the image we would use</p><pre>[node:field_image:entity:field_media_image:metatag_image:height]<br>[node:field_image:entity:field_media_image:metatag_image:width]</pre><p>So this can become more complex than just adding a token to a field.</p><h4>OpenGraph types</h4><p>The ‘Content type’-field suggests, by being a text field, that any text can be entered here. There is however a strict list of allowed type you can use here, see <a href="https://ogp.me/#types">https://ogp.me/#types</a>.</p><h4>Twitter card-type</h4><p>For ‘normal’, mainly text content ‘Summary Card with large image’ is the preferred type. If you have content that consists mainly of photo’s or streaming media, or an IOS or Android app, you can add overrides for that type via the ‘Add default meta tags’-button. Do not the explanation beneath the ‘Image URL’ field which states:</p><blockquote><em>The URL to a unique image representing the content of the page. Do not use a generic image such as your website logo, author photo, or other image that spans multiple pages. Images larger than 120x120px will be resized and cropped square based on longest dimension. Images smaller than 60x60px will not be shown. If the ‘type’ is set to Photo then the image must be at least 280x150px. This will be able to extract the URL from an image field. This will be able to extract the URL from an image field.</em></blockquote><h4>Schema.org Author &amp; Publisher</h4><p>At first sight it may seem a good idea to use @type ‘Person’ and the [node:author] token here, but keep in mind that in most cases this wil show data about persons whose data is not publicly available, for example the webmaster or site editors.</p><p>As a rule of thumb only show the author for content like blogs which has a strong connection to the person who wrote it. For most content it is a better choice to use the @type ‘Organization’ and use the site URL as @id and the site name as name. And again make sure to use a valid image style for the logo and to set <strong>representative Of Page</strong> to ‘False’.</p><h3>Taxonomy term</h3><p>Make sure to set these if you have taxonomy pages that are publicly available. Like with content, the tokens for taxonomy terms are only available here, and not in the global section. And just as witch ‘Content’, you can use the ‘Add default meta tags’-button if you have special requirements for a taxonomy.</p><p>Beware that taxonomy terms have different names, e.g. [node:title] vs. [term:name] and that you should alway use term instead of node as the base of the tokens.</p><h3>User</h3><p>As always make sure you are not sharing too much information about your users in the meta tags, like the account name or the user id.</p><p>Fields that are not shown on the user pages will still be available in the tokens, so make sure you check which fields are public and which are not. And these meta tags only make sense if the user pages are publicly available.</p><h3>Testing meta tags</h3><p>The first, basic test is to check the source if the different pages and make sure that you see the meta tags and the content you expect. In some cases the meta tag will not be shown because the token used did not render any content, maybe because the field the token referred to is not a required field and the default set in the ‘Global’ section is not set.</p><p>Other common pitfalls are content types that use different fields for the same functionality, like a hero image that is only available on blogs. If this is the case you can override the meta tags by adding default settings for that specific content type.</p><p>But always make sure you examine the source for at least one item of each content type to make sure the correct tags are rendered and do not <em>assume</em> it will work.</p><h3>Local testing</h3><p>To use the testing tools for Twitter cards and OpenGRAPH (used by Facebook) your site must be publicly available before you can use the test tool. If we do not take into account tunnelling services like ‘ngrok’ or elaborate router configurations, this means that you cannot test these meta tags before deployment.</p><p>So make sure to set all the correct values before deployment and, because perfection does not exists, make some room in your planning to test and re-deploy the meta tags once the site is live.</p><h3>Testing Twitter cards</h3><p>To test your Twitter cards meta tags you can use the testing tool at</p><p><a href="https://cards-dev.twitter.com/validator">https://cards-dev.twitter.com/validator</a></p><p>For this page you must login and so a Twitter account is required. This tools only validates site that are publicly available so you can only use if after the site has gone into production.</p><p>But it seems that this tool currently has some problems and only gives the message ‘Unable to render Card preview’, even for sites that render perfectly fine when mentioned in a tweet. Which, by the way, is another method to test your site because the preview will be rendered before you actually place the tweet.</p><h3>Testing OpenGraph</h3><p>The testing tool from Facebook</p><p><a href="https://developers.facebook.com/tools/debug/sharing/">https://developers.facebook.com/tools/debug/sharing/</a></p><p>is available with a Facebook account and gives a detailed overview of the issues present in your webpage.</p><p>By default the tool uses a scraped version of the site, which makes it a bit harder to iteratively perfect your meta tags. Make sure to update the scraped version with the ‘Scrape again’-button under the ‘When and how we last scraped the URL’-button if you updated the meta tags.</p><h3>Testing Schema.org</h3><p>Google had a rather fine working testing tool at</p><p><a href="https://search.google.com/structured-data/testing-tool?hl=en">https://search.google.com/structured-data/testing-tool?hl=en</a></p><p>but decided to deprecate it in favour of</p><p><a href="https://search.google.com/test/rich-results">https://search.google.com/test/rich-results</a></p><p>which however does not has the ability to test off line sites anymore (because even if you use the code option all resources need to be be accessible) and seems to have problems with generated images in some cases, without specifying exactly what the error is.</p><p>Of course there are other tools, but most of them not free and mainly targeted at check the validity of the generated JSON-LD (which is not a major problem in Drupal because the module generates it).</p><h3>But I expected…</h3><p>You did not expect I would tell you what value to use for each of the settings, did you? First, this largely depends on the entities you defined in Drupal. of course I can tell you that you should use a field with name ‘field_description’ for the meta tag description, but chance is you read this blog long after all entities were defined.</p><p>So no, I will not tell you what to put where, but I hope you understand more about what to put why.</p><h3>Documentation and links</h3><ul><li>Meta tags module: <a href="https://www.drupal.org/docs/8/modules/metatag">https://www.drupal.org/docs/8/modules/metatag</a></li><li>Twitter cards: <a href="https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/abouts-cards">https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/abouts-cards</a></li><li>OpenGraph: <a href="https://ogp.me/">https://ogp.me</a></li><li>Schema.org: <a href="https://json-ld.org/">https://json-ld.org/</a></li><li>Facebook (only with Facebook account): <a href="https://developers.facebook.com/tools/debug/sharing/">https://developers.facebook.com/tools/debug/sharing/</a></li><li>Twittercards validation: <a href="https://cards-dev.twitter.com/validator">https://cards-dev.twitter.com/validator</a></li><li>About Twittercards: <a href="https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/abouts-cards">https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/abouts-cards</a></li><li>Google: https://search.google.com/test/rich-results</li><li>About the viewport meta tag: <a href="https://www.davidbcalhoun.com/2010/the-viewport-metatag-mobile-web-part-1/">https://www.davidbcalhoun.com/2010/the-viewport-metatag-mobile-web-part-1/</a></li><li>About the handheld friendly meta tag:<a href="https://www.metatags.nl/2015/06/metatags-mobiel/mobiele-metatags-voor-de-smartphone/">https://www.metatags.nl/2015/06/metatags-mobiel/mobiele-metatags-voor-de-smartphone/</a></li><li>About the description meta tag: <a href="https://www.metatags.org/all-meta-tags-overview/the-important-meta-tags/meta-name-description/">https://www.metatags.org/all-meta-tags-overview/the-important-meta-tags/meta-name-description/</a></li></ul><p>Louis Nagtegaal is all round digital specialist at LimoenGroen with a strong focus on back-end development. LimoenGroen (Dutch for ‘lime green’) is a team of passionate people working with Drupal for a broad range of clients. We provide user-centric, scalable websites and digital solutions that will add lasting value to organizations. With a strong focus on web accessibility and open source, we care to share. We are based in Amsterdam, The Netherlands. We have worked for many top Dutch and international brands including <a href="https://www.limoengroen.nl/project/iucn-website-wordt-gebruiksvriendelijk-en-efficient">IUCN</a>, <a href="https://www.limoengroen.nl/project/24kitchennl">Fox</a> and <a href="https://www.limoengroen.nl/project/drupal-in-space">ESA</a>. Would you like to know more about meta tags, accessibility or web development? Contact Louis at louis@limoengroen.nl .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b0b057b0392" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/stop-loneliness-8b0b057b0392">Stop loneliness, a story about meta tags in Drupal</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React vs. Vue.js in 2020 — maakt het nog uit?]]></title>
            <link>https://medium.com/limoengroen/react-vs-vue-js-in-2020-maakt-het-nog-uit-2572ff7b3270?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/2572ff7b3270</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Marc van Gend]]></dc:creator>
            <pubDate>Fri, 26 Jun 2020 12:15:27 GMT</pubDate>
            <atom:updated>2020-06-26T12:15:27.754Z</atom:updated>
            <content:encoded><![CDATA[<h3>React vs. Vue.js in 2020 — maakt het nog uit?</h3><p>Een paar jaar geleden had ik een sterke voorkeur voor Vue.js, vergeleken met andere frameworks zoals React, Ember of Angular. Vue was vergeleken met React overzichtelijker, makkelijker te leren, had een beter open source licentiemodel, betere documentatie, en was groot genoeg gegroeid om een levensvatbare community met stabiele packages te onderhouden.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ArqVrKvWOT8TsyetZVxnRg.jpeg" /></figure><p>De afgelopen maanden werkte ik aan twee projecten, een op basis van <a href="https://vuejs.org/">Vue.js</a>, de ander gebouwd met <a href="https://reactjs.org/">React</a>. Een uitgelezen kans om eens de balans op te maken: Hoe staat het ervoor met deze frameworks, waar word ik blij van als ontwikkelaar, waar kan ik onze klanten het best mee bedienen… en maakt het sowieso nog uit?</p><h3>Setup</h3><p>De setup van een nieuw project is voor beide systemen erg vergelijkbaar als je de bijbehorende scaffolding tool gebruikt. Of je nu npx create-react-app of vue create draait, er is weinig verschil. Je krijgt een basis directory structuur, uitgerust met package manager, build- en develop-tasks, Webpack, Babel, ESlint, Autoprefixer en nog meer. De Vue CLI generator biedt wat meer opties die je kan configureren. Beide systemen kennen een concept van plugins/templates om de generator aan te passen naar je eigen smaak, als je het belangrijk vindt om dat eigen smaakje te automatiseren. Je kan hoe dan ook snel van start met bouwen.</p><h3>Componenten</h3><h4>React</h4><p>React heeft verschillende manieren om componenten te definiëren. De meer moderne (en m.i. beter leesbare manier) is om function components te schrijven ipv. class components. Dat houdt in dat je een component maakt door simpelweg een JavaScript functie te schrijven. Function components hadden voorheen nog beperkingen, maar met de introductie van “hooks” in React 16.8 is dat geen issue meer.</p><p>React gebruikt JSX, een variant op JavaScript die het geschikt maakt om HTML markup met dynamische JS code te combineren. Ook CSS wordt vaak met JS gegenereerd, waardoor het wellicht niet direct vertrouwd aanvoelt voor frontend developers die gewend zijn om CSS of Sass code te schrijven.</p><p>Als je React-component gebruikt maakt van sub-components die verder niet herbruikbaar hoeven te zijn, kan je die gewoon bundelen in hetzelfde bestand. Denk bijvoorbeeld aan een situatie waar een ToDoList component een lijst opbouwt van ToDoItem components. Als je het ToDoItem niet ergens anders wil hergebruiken, kan je gerust in hetzelfde bestand bundelen.</p><p>Al met al biedt React flexibiliteit maar soms ook verwarring over wat nu de “juiste” manier is. Dat effect wordt nog versterkt doordat het maar al te makkelijk is om verouderde technieken terug te vinden in blogposts, StackOverflow antwoorden en NPM packages. Het is zinvol om daar als tech lead een keuze in te maken om zo wat consistentie af te dwingen.</p><h4>Vue</h4><p>Hoewel er voor een speciale gevallen ook andere methodes zijn, zal je in Vue vooral componenten schrijven in de vorm van “Single File Components” (SFC). Dat is een enkel bestand waarin 3 afzonderlijke delen los van elkaar te herkennen zijn: een &lt;template&gt; voor de HTML markup (met wat toevoegingen voor bv. dynamische data en loops), &lt;script&gt; voor al je JavaScript (bijvoorbeeld dynamische data en interactie), en optioneel &lt;style&gt; voor CSS (of Sass / Scss). Dit nodigt het automatisch uit tot een nette scheiding van structuur, gedrag en vorm. Bovendien draagt het eraan bij dat veel developers, waaronder ikzelf, een minder steile learning curve zeggen te ervaren bij Vue. Er is namelijk minder twijfel over welke code waar hoort en de code die je schrijft lijkt mogelijk meer op wat je al kent.</p><p>In tegenstelling tot React heeft Vue geen elegante oplossing voor sub-components in hetzelfde bestand. Dus ook als je ToDoItem component onlosmakelijk verbonden is aan je ToDoList, maak je er een apart bestand voor. Of dat een nadeel is, mag de lezer zelf beslissen; Het voelt soms een beetje omslachtig, maar omwille van consistentie valt er zeker ook wat voor te zeggen voor een strikte toepassing van de “1 component = 1 file” logica.</p><h4>Voorbeelden</h4><p>Ter vergelijk twee eenvoudige, gelijkwaardige componenten in React en Vue. Hierbij gaan we er vanuit dat een array met ToDo objecten wordt meegegeven aan dit component. Je ziet duidelijk hoe het React component een enkele JS functie is, terwijl het Vue component uit twee delen bestaat.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d69b10f3415a78b1f7d1da81b00509ef/href">https://medium.com/media/d69b10f3415a78b1f7d1da81b00509ef/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f88f9584cc37a5cbccbf3345fa5897f1/href">https://medium.com/media/f88f9584cc37a5cbccbf3345fa5897f1/href</a></iframe><h3>Virtual DOM</h3><p>Om een webpagina te tonen, zal een browser “onder de motorkap” een schematisch model opbouwen van de structuur van de pagina. Dit wordt de Document Object Model (DOM) genoemd. JavaScript frameworks doen hun werk door wanneer nodig de DOM te veranderen. Het manipuleren van de DOM kost wel rekenkracht van de computer, dus moet zo efficient mogelijk gebeuren.</p><p>Vue en React gebruiken het “Virtual DOM” principe om de pagina op te bouwen, te bepalen welke delen veranderd zijn, en alleen die delen in de DOM bij te werken. Een <a href="https://vuejs.org/v2/guide/comparison.html#Runtime-Performance">vergelijking</a> van beide frameworks op vuejs.org beschrijft het verschil tussen de twee implementaties:</p><blockquote>In React, when a component’s state changes, it triggers the re-render of the entire component sub-tree, starting at that component as root. […] In Vue, a component’s dependencies are automatically tracked during its render, so the system knows precisely which components actually need to re-render when state changes.</blockquote><p>Met andere woorden, als de data in component X verandert, zal React normaliter alle onderliggende components ook opnieuw renderen. Vue probeert daar slimmer mee om te gaan. In React kan je wel het onnodig re-renderen van components voorkomen, bv. met React.memo. Vue kan dat automatisch omdat je in een component expliciet de data, components en props definieert waar je component van afhankelijk is. (Voor wie een achtergond heeft in Drupal: dat is een beetje zoals je in Drupal cacheability metadata toevoegt aan je render array). <a href="https://stefankrause.net/js-frameworks-benchmark8/table.html">Vergelijkende tests</a> laten zien dat de performance van Vue, mede hierdoor, iets beter is dan die van React. De ontwikkelaars van Vue <a href="https://medium.com/vue-mastery/evan-you-previews-vue-js-3-0-ab063dec3547">claimen</a> bovendien dat Vue versie 3 (verwacht: eind Q2 2020) nog sneller is op dit vlak.</p><h3>Styling</h3><p>Beide frameworks zijn sterk gericht op componenten die zowel qua functie als vormgeving op zichzelf kunnen staan. Dat is een concept dat zeer behulpzaam is voor frontend developers en het stimuleert om goed na te denken over de architectuur van de site. Tegelijk zijn er altijd dingen die je niet per component, maar site-wide wil definiëren. Denk bv. aan tekstgrootte of kleuren. Binnen Drupal projecten gebruiken we daarvoor vaak Sass. Vue biedt uitstekende ondersteuning voor Sass binnen het &lt;style&gt; gedeelte van een SFC, dus al die ervaring en code kan worden meegenomen naar een Vue project. Binnen React projecten is de ondersteuning voor Sass veel minder, en omdat het hele systeem toch al veel sterker op JavaScript gebaseerd is, ligt het voor de hand om daar gebruik te maken van de populaire Styled Components package. Veel van de concepten die we van Sass kennen, zoals geneste selectors, variabelen, functies en mixins, kunnen ook met Styled Components in JavaScript toegepast worden.</p><p>Styling met Styled Components in React is even wennen, maar het is zeker goed te doen. Grappig genoeg bleek het voor mij soms ook een nadeel dat de Sass ondersteuning in Vue zo goed is, want de verleiding is groot om veel te veel standaardcode te kopiëren uit eerdere projecten, terwijl je veel minder technical debt opbouwt als je met een frisse blik en een lege bladzijde ergens aan begint.</p><h3>Ecosysteem</h3><p>Zowel Vue als React hebben een gezond ecosysteem van plugins. De paralellen met de welbekende Wordpress-vs-Drupal vergelijkingen zijn sterk. Het systeem dat groter is in gebruikersaantal, React, heeft ook een veel groter aantal packages dat daarvoor geschreven is. De community achter Vue is echter ook groot genoeg om kant en klare code te kunnen bieden voor veelgebruikte functionaliteit. Het grote aantal React plugins betekent ook dat het soms moeilijk kiezen is, en de snelle ontwikkeling van het React framework zorgt ervoor dat je wat vaker verouderde code tegenkomt.</p><p>React kent een tweetal plugins, Redux en React Router, die zo veel gebruikt worden dat ze de de facto standaard zijn geworden voor respectievelijk state management en routing. Toch zijn het losstaande packages, met hun eigen maintainers, release cycle, websites en documentatie. Bij Vue worden vergelijkbare packages, Vuex en Vue Router, onderhouden door het Vue core team zelf. Dat laatste pleit wat mij betreft voor Vue, zeker als je ziet hoe enorm verschillend de documentatie van de diverse packages kan zijn.</p><p>React en Vue zijn kunnen direct ingezet worden als flexibele basis voor een web applicatie, maar zijn ook een goede basis gebleken voor meer gefocuste frameworks. Zoals de React community Gatsby en Next heeft opgeleverd, zijn er Nuxt en Gridsome voor Vue.js. Deze systemen kunnen helpen om nog sneller vaak gebruikte functies neer te zetten. Doordat ze elkaar goed in de gaten houden, bieden ze in grote lijnen dezelfde mogelijkheden.</p><h3>Toekomst</h3><p>Zoals gezegd wordt binnen afzienbare tijd Vue 3 verwacht. Daar zitten een paar flinke toevoegingen in waar veel mensen in de Vue community erg enthousiast over zijn — hoewel er initieel ook <a href="https://dev.to/danielelkington/vue-s-darkest-day-3fgh">weerstand</a> was. De belangrijkste daarvan is wellicht de <a href="https://composition-api.vuejs.org/">Composition API</a>, die het makkelijker moet maken om logica te groeperen, afscheiden en hergebruiken tussen verschillende components. Ook wordt Vue 3 geschreven in typescript, wat de codekwaliteit ten goede kan komen. Tegelijkertijd is het moeilijk te zeggen hoe lang het zal duren voordat Vue 3 echt voldoende ondersteund wordt binnen het ecosysteem. Ik kijk zelf uit naar Vue 3, maar voor de nabije toekomst lijkt React een veiliger keuze.</p><p>De updates van React hebben een hoger tempo en ook minor versions kunnen significante uitbreidingen bevatten. Dat zorgt ervoor dat je goed moet opletten hoe oud een artikel / blogpost / Q&amp;A is als je iets opzoekt op internet. Het heeft er echter ook voor gezorgd dat ik inmiddels een stuk positiever ben over React dan voorheen, want function components en hooks werken prettig.</p><h3>Conclusie</h3><p>Drie jaar geleden had ik een sterke voorkeur voor Vue ipv. React, maar er is veel veranderd. De <a href="https://thenextweb.com/dd/2017/09/25/facebook-re-licenses-react-mit-license-developer-backlash/">switch</a> van React naar een MIT licentie vond ik persoonlijk belangrijk, zeker ook voor de integratie met open source projecten als Drupal. Maar ook de developer experience is wat mij betreft vooruit gegaan en de learning curve lijkt minder steil — al is het onmogelijk voor mij om dat echt te beoordelen, omdat iets maar één keer echt nieuw kan zijn. Tegelijk heeft Vue zich minder snel ontwikkeld dan ik misschien gehoopt had. Door de performance en de Single File Components heb ik nog een lichte voorkeur voor de technische kant van Vue en de toekomstplannen zijn veelbelovend. Misschien kan Vue het voordeel weer verder uitbouwen, maar de toekomst zal moeten uitwijzen hoe zich dat gaat verhouden tot de overmacht die React momenteel heeft.</p><p>Photo by <a href="https://unsplash.com/@gcalebjones?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Caleb Jones</a> on <a href="https://unsplash.com/s/photos/choice?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2572ff7b3270" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/react-vs-vue-js-in-2020-maakt-het-nog-uit-2572ff7b3270">React vs. Vue.js in 2020 — maakt het nog uit?</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Van beginnend Drupal stagiair naar eerste Drupal patch.]]></title>
            <link>https://medium.com/limoengroen/van-beginnend-drupal-stagiair-naar-eerste-drupal-patch-7ef0a7160df6?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/7ef0a7160df6</guid>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[internships]]></category>
            <dc:creator><![CDATA[Tonny Su]]></dc:creator>
            <pubDate>Wed, 27 May 2020 12:10:51 GMT</pubDate>
            <atom:updated>2020-05-27T12:21:35.751Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>De één maand Drupal basisopleiding van LimoenGroen is voorbij en ik ben ondertussen mee aan het draaien in projecten. Ik draag ook bij aan Beheer en Ondersteuning, waar mijn taak is om websites technisch up-to-date te houden. Dat houdt onder meer in dat updates van Drupal core en de gebruikte community-modules geïnstalleerd worden. Soms constateren we een fout in de module code wanneer we deze updaten. Er moet dan een patch geschreven worden.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cWzVYTDuIWXW36NPZDweVA.jpeg" /><figcaption>Foto van <a href="https://unsplash.com/@grohsfabian">Fabian Grohs</a></figcaption></figure><h4>Auto Purge Users</h4><p>De module Auto Purge Users is een extensie van Drupal core waarmee website administrators gemakkelijk gebruikersaccounts kunnen verwijderen op basis van inactiviteit. Modules worden door de open source Drupal community gemaakt en het kan wel eens voorkomen dat er bugs aanwezig zijn. Zo zag ik bij het testen van deze module dat ook gebruikersaccounts verwijderd werden waarvan het niet de bedoeling was. Samen met Drupal support developer Gerben keken wij naar de module code en merkten wij dat er een fout in de query zat voor het bepalen welke accounts verwijderd worden. De Auto Purge Users module wordt wereldwijd door honderden websites gebruikt en dit kan leiden tot problemen.</p><h4>Patch</h4><p>De volgende stap is dan om de code te verbeteren en dit als patch door te geven aan de module maker. Een patch file is handig, omdat je daarin precies kan zien welke veranderingen plaats zijn gevonden. In een <a href="https://www.drupal.org/project/purge_users/issues/3136200">bug report</a> van de Auto Purge Users module gaf ik aan hoe de fout gereproduceerd kan worden samen met de verbeterde code in vorm van een patch file.</p><p>Inmiddels heeft de module maker deze verandering toegepast en kan ik zeggen dat dit mijn <a href="https://www.drupal.org/u/stonnyu/issue-credits">eerste bijdrage</a> is aan Drupal!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ef0a7160df6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/van-beginnend-drupal-stagiair-naar-eerste-drupal-patch-7ef0a7160df6">Van beginnend Drupal stagiair naar eerste Drupal patch.</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digitale toegankelijkheid: de 7 meest gemaakte fouten]]></title>
            <link>https://medium.com/limoengroen/digitale-toegankelijkheid-de-7-meest-gemaakte-fouten-d2fa0f52dd44?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/d2fa0f52dd44</guid>
            <category><![CDATA[gaad]]></category>
            <category><![CDATA[toegankelijkheid]]></category>
            <category><![CDATA[digital-accessibility]]></category>
            <category><![CDATA[accessibility]]></category>
            <dc:creator><![CDATA[Marloes Bosch]]></dc:creator>
            <pubDate>Wed, 20 May 2020 11:46:52 GMT</pubDate>
            <atom:updated>2020-05-20T12:34:56.461Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Donderdag 21 mei 2020 is het </strong><a href="https://globalaccessibilityawarenessday.org/"><strong>Global Accessibility Awareness Day</strong></a><strong> (GAAD). Op deze dag is er extra aandacht voor toegankelijkheid en inclusie om meer bewustzijn rondom deze thema’s te creëren . Toegankelijkheid en inclusie hebben betrekking op bijna alles, zoals gebouwen en evenementen, maar ook websites en apps. Digitale toepassingen schieten nu vaak tekort. Dat is zonde, want je benadeelt een </strong><a href="https://www.inclusivecitymaker.com/disabled-people-in-the-world-in-2019-facts-and-figures/"><strong>groot deel van je doelgroep</strong></a><strong> en je </strong><a href="https://moz.com/blog/seo-accessibility-formatting-and-links"><strong>scoort minder goed in Google</strong></a><strong>. Dit zijn de zeven meest gemaakte webtoegankelijkheidsfouten (en de oplossingen).</strong></p><p>Digitale toegankelijkheid en inclusie zorgt ervoor dat een technologie voor <strong>iedereen </strong>goed werkt. De harde realiteit is alleen dat <a href="https://www.who.int/news-room/fact-sheets/detail/disability-and-health">meer dan een miljard mensen wereldwijd met een chronische beperking</a> dagelijks geconfronteerd worden met ontoegankelijke websites, apps en andere technologieën. Ook als je geen chronische beperking hebt, kun je geraakt worden door ontoegankelijkheid. Je breekt je arm en je kunt je muis niet gebruiken. Je troost je huilende baby in je arm, terwijl je een rapport aan het schrijven bent. Je internet is te traag om te kunnen deelnemen aan die ene belangrijke videovergadering die over vijf minuten begint. Of je staat met je mobiel in de felle zon, waardoor je niet goed kunt lezen wat er op je scherm staat. Allemaal zijn we wel eens beperkt, situationeel, tijdelijk en/of chronisch. Zeker nu we door de corona-crisis afhankelijk(er) zijn van digitale kanalen is het extra belangrijk om aandacht te besteden aan digitale toegankelijkheid. Om die reden zal ik in deze post ingaan op de zeven meest gemaakte webtoegankelijkheidsfouten:</p><ol><li>Te laag tekst contrast</li><li>Ontbrekende alternatieve tekst voor afbeeldingen</li><li>Links zonder tekst en ontbrekende href</li><li>Knoppen zonder tekst</li><li>Ontbrekende formulier labels</li><li>Ontbrekende taal attribuut</li><li>Onzichtbare focus aanwijzer</li></ol><p>De eerste zes fouten komen naar voren uit een analyse van <a href="https://webaim.org/about/">WebAIM</a>. In deze <a href="https://webaim.org/projects/million/">toegankelijkheidsanalyse </a>zijn een miljoen websites onderzocht met <a href="https://wave.webaim.org/">WAVE, een automatische test-tool</a>. De zevende fout kom ik zelf dagelijks tegen in de praktijk en vind ik daarom de moeite waard om te benoemen.</p><h3>1. Te laag contrast</h3><p>Als het contrast van de tekst te laag is, is het heel lastig om de tekst goed te kunnen lezen. Hoe kleiner het verschil tussen de tekstkleur en de achtergrondkleur, hoe moeilijker de tekst te lezen is. Vooral voor mensen die slechtziend, kleurenblind of dyslectisch zijn, kan het lezen van tekst met een te laag contrast lastig zijn. Wanneer is het contrast voldoende? Als de voorgrondkleur en de achtergrondkleur minimaal een <a href="https://www.w3.org/TR/WCAG21/#contrast-minimum">verhouding hebben van 4.5:1</a>. Dit kun je controleren met een <a href="https://webaim.org/resources/contrastchecker/">contrast-checker</a>. In de checker vul je de voorgrondkleur en de achtergrondkleur in. Op basis van die waardes wordt de contrast ratio berekend. Als de normale tekst op AA niveau een “pass” (geslaagd) aangeeft, dan is het contrast van de tekst voldoende. Als de test faalt, is het belangrijk dat je de tekstkleur donkerder maakt. De <a href="https://learnui.design/tools/accessible-color-generator.html?colors=86bd01">accessible color generator</a> is een handige hulp hierbij. De generator berekent de kleur die het meest op jouw ingevoerde tekstkleur lijkt, maar die wel voldoende contrast heeft met de achtergrond.</p><figure><img alt="Twee voorbeelden met tekst, waarvan één voorbeeld met een te laag contrast en één voorbeeld met voldoende contrast." src="https://cdn-images-1.medium.com/max/756/1*32_EzkF_P-u-8ZpT3GWQnQ.png" /><figcaption><em>Twee voorbeelden met lorem ipsum tekst. Eén voorbeeld met een te laag contrast en één voorbeeld met voldoende contrast.</em></figcaption></figure><h3>2. Ontbrekende alternatieve tekst voor afbeeldingen</h3><p>Een <a href="https://www.w3.org/TR/WCAG21/#text-alternatives">alternatieve tekst</a> van een afbeelding beschrijft wat er op de afbeelding te zien is. De alternatieve tekst wordt aan de afbeelding toegevoegd door middel van een “alt-attribuut”: &lt;img alt=”alternatieve tekst” /&gt;. Hiermee kun je het doel van de afbeelding overbrengen op gebruikers die de afbeelding niet visueel kunnen zien. Benoem details van de foto in je alternatieve tekst, maar <a href="https://support.siteimprove.com/hc/en-gb/articles/115000013031-Accessibility-Image-Alt-text-best-practices">houd het wel beknopt</a>. Je hoeft de alternatieve tekst ook niet te beginnen met “foto van” of “afbeelding van”. Een <a href="https://www.accessibility.nl/kennisbank/artikelen/over-screenreaders-gesproken-(deel-1)">screenreader</a> zal al uit zichzelf benoemen dat het een afbeelding is. Als je “afbeelding van” dan ook in de alternatieve tekst verwerkt, wordt dit dubbel voorgelezen. Bijvoorbeeld: “afbeelding van een appel”; Dan wordt het volgende voorgelezen: “afbeelding, afbeelding van een appel.</p><p>Heeft elke afbeelding een alternatieve tekst nodig? Nee, dat niet. Soms gebruik je een afbeelding puur voor decoratie. De decoratie heeft dan geen alternatieve tekst nodig, maar het is wel belangrijk dat je aangeeft dat het om een decoratie gaat. In dit geval voeg je de “alt-attribuut” toe aan de afbeelding, maar laat je deze leeg. Dus:&lt;img alt=”” /&gt;. Hiermee geef je duidelijk aan dat de bezoeker niet hoeft te zien wat er op de afbeelding staat om de context van het verhaal te kunnen begrijpen. De afbeelding brengt dan geen informatie over.</p><h3>3. Links zonder tekst en ontbrekende href</h3><p><strong>Ontbrekende linktekst<br></strong>Het <a href="https://www.w3.org/WAI/WCAG21/Understanding/link-purpose-in-context">doel van de linktekst</a> is dat het beschrijft waar de link naar toe gaat. Vooral voor bezoekers met een visuele of cognitieve beperking en die gebruik maken van een screenreader, Braille of spraakinput is het moeilijk om te navigeren op je website als de linkteksten leeg zijn. Een goede linktekst vertelt je wat je te wachten staat als je op de link klikt, zonder dat je de omliggende tekst hoeft te lezen. Linkteksten als “klik hier” of “lees meer” zijn daarom niet duidelijk. Waar is “hier” als je het niet kan zien? Of waar ga ik dan meer over lezen? Omschrijf dat ook in je linktekst. Maak je linktekst omschrijvend. Lees meer over onderwerp X, bijvoorbeeld. Daaruit wordt duidelijk dat ik iets meer ga lezen over onderwerp X. Met alleen “lees meer” had ik dit niet kunnen achterhalen.</p><p><strong>Ontbrekende href<br></strong>Een lege link is ook een link die nergens naar toe gaat. In dit geval <a href="https://dequeuniversity.com/rules/axe/3.0/href-no-hash">ontbreekt het “href-attribuut”</a>. In de &lt;a href=”#”&gt; wordt normaal benoemd waar de link naartoe navigeert. Dit kan een andere pagina op je website zijn, of een anker naar een ander deel op dezelfde pagina. Ontwikkelaars misbruiken links wel eens om acties uit te voeren. Denk hierbij aan het openen van een menu. De link leidt dan niet naar een andere pagina, maar het activeert een actie. Een voorbeeld van het *misbruiken* van een link: &lt;a onmouseover=”openMenu()”&gt;Menu&lt;/a&gt;. De link gaat nergens heen, want er is geen href. Met onmouseover, oftewel “met de muis er overheen”, kun je wel een actie uitvoeren: het menu openen. Dit stukje code heeft als gevolg dat alleen een muis-gebruiker het menu kan openen door over de link heen te bewegen. Een bezoeker die geen muis gebruikt, zoals een screenreader gebruiker, kan het menu in dit geval niet openen.</p><h3>4. Knoppen zonder tekst</h3><p>Als je je gebruiker een actie wil laten uitvoeren, zoals het openen van een menu, vervang de lege link dan met een knop: &lt;button&gt;. Een link gaat namelijk ergens naar toe en een <a href="https://www.w3.org/TR/wai-aria-practices-1.1/#button">knop start een actie</a>. Ook voor knoppen geldt dat ze niet ‘leeg’ mogen zijn. Er moet dus altijd een knoptekst aanwezig zijn die aangeeft wat voor actie het gaat uitvoeren als je er op klikt.</p><p>Wat als ik geen zichtbare tekst op mijn knop wil tonen? De menu knop is hier een goed voorbeeld van. De menuknop op mobiel bestaat meestal alleen uit drie streepjes zonder tekst.</p><figure><img alt="Een menu knop met drie zwarte streepjes, zonder tekst." src="https://cdn-images-1.medium.com/max/68/1*827a7HHJffZv7fn4kCdaNQ.png" /><figcaption>Een hamburger menu knop.</figcaption></figure><p>Om er toch voor te zorgen dat onder andere screenreader gebruikers kunnen bepalen wat de knop doet, kun je een tekst aan de knop toevoegen die visueel verborgen is. De tekst staat er dan wel, maar je ziet het alleen niet. Er zijn meerdere CSS technieken om <a href="https://webaim.org/techniques/css/invisiblecontent/">tekst toegankelijk te verbergen</a>. Een voorbeeld hiervan is:</p><pre>&lt;button type=”button”&gt;<br>  &lt;img src=”menu-streepjes” alt=”” /&gt;<br>  &lt;span class=”visually-hidden”&gt;Menu openen&lt;/span&gt;<br>&lt;/button&gt;</pre><p>De visually-hidden class voegt styling toe waardoor je “menu openen” visueel niet ziet staan, maar het zorgt er wel voor dat het voorgelezen kan worden door onder andere screenreaders. Hiermee is het doel van de knop duidelijk: het openen van het menu.</p><h3>5. Ontbrekende formulier labels</h3><p>Labels bij formuliervelden geven aan wat je in het veld moet invullen. <a href="https://joshuawinn.com/ux-input-placeholders-are-not-labels/">Een label is <strong>niet</strong> hetzelfde als een placeholder.</a> Een placeholder kan een hint geven over wat je moet invullen, maar de placeholder verdwijnt wanneer je begint met typen in het invoerveld. Vooral bij lange formulieren kan het erg frustrerend zijn als er geen label boven het invoerveld staat. Wat als je wilt controleren of je alle velden goed hebt ingevuld? Het is lastig om voor elk veld precies te onthouden waar het voor dient, zeker voor mensen met een cognitieve beperking of korte-termijn geheugen. Dan zou je de invoertekst weg moeten halen om de placeholder weer zichtbaar te krijgen. Daarom raad ik aan altijd een label boven het invoerveld te plaatsen. Het liefst goed zichtbaar, zodat je niet voor elk veld hoeft te onthouden waar het voor dient. Een <a href="https://www.w3.org/WAI/tutorials/forms/labels/">label koppel je aan de input</a> met een id.</p><pre>&lt;label for=&quot;gebruikersnaam&quot;&gt;<br>&lt;input id=&quot;gebruikersnaam&quot; type=&quot;text&quot; /&gt;</pre><figure><img alt="Twee voorbeelden van een formulier, waarvan één voorbeeld zonder formulier labels en één met formulier labels." src="https://cdn-images-1.medium.com/max/1024/1*XhgaA452NvxKDISlKpHo4A.png" /><figcaption>Twee formulieren met dezelfde invoervelden. Eén voorbeeld heeft geen labels boven de invoervelden. Het andere voorbeeld heeft wel visueel zichtbare formulier labels.</figcaption></figure><h3>6. Ontbrekend taal attribuut</h3><p>Voor je website is het belangrijk dat je een <a href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/meaning-doc-lang-id.html">hoofdtaal instelt</a>. Hierdoor begrijpt je browser hoe tekst gepresenteerd moet worden. Ook zorgt het toekennen van een taal er voor dat screenreaders de tekst makkelijker kunnen verwerken en in de taal van jouw website kunnen voorlezen. Je kunt een taal toekennen door middel van het “lang-attribuut”. Als je een &lt;html lang=”nl”&gt; gebruik, geef je aan dat je website Nederlands is. Is je website in een andere taal? Dan kun je een andere taalcode gebruiken. Voor elke taal is er een <a href="https://www.sitepoint.com/iso-2-letter-language-codes/">taalcode beschikbaar</a>. Heb je een meertalige website? Let er dan op dat het “lang-attribuut” wijzigt in de taal die is ingesteld door de gebruiker.</p><h3>7. Onzichtbare focus aanwijzer</h3><p>Wil je een toegankelijke website hebben, dan dient je <a href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/keyboard-operation-keyboard-operable.html">site volledig bedienbaar te zijn met een toetsenbord</a>. Met een toetsenbord zou je onder andere links kunnen openen, knoppen kunnen activeren en invoervelden kunnen invullen. Om met je toetsenbord te kunnen navigeren, is het belangrijk dat je kunt zien waar je met je toetsenbord bent. Als je met je muis navigeert, zie je een pijltje. Als je met je toetsenbord navigeert zie je geen pijltje, maar een andere focus aanwijzer: een focus outline. In de praktijk wordt deze outline vaak onzichtbaar gemaakt door ontwikkelaars. Dit maakt het onmogelijk om gebruik te kunnen maken van je website met een toetsenbord. Stel je eens voor dat je als muis-gebruiker het pijltje van de muis niet meer ziet. Hoe weet je dan waar je bent of waar je klikt? Het verwijderen van de focus outline heeft hetzelfde effect voor mensen die alleen gebruik maken van een toetsenbord in plaats van een muis. CSS code als *:focus { outline: 0 } moet je daarom bij voorkeur <strong>nooit</strong> toevoegen. Dit maakt de focus aanwijzer onzichtbaar. Haal je de focus aanwijzer wel weg? Zorg dan wel voor een goede vervanger.</p><h3>Conclusie</h3><p>Bovengenoemde zeven fouten maken je website ontoegankelijk(er). Daarom deze checklist om de meest gemaakte fouten te voorkomen:</p><ol><li>Tekst heeft minimaal een contrastwaarde van 4.5:1</li><li>Afbeeldingen die belangrijk zijn om de context te begrijpen, hebben een alt-tekst waarin beschreven staat wat er op de afbeelding te zien is</li><li>Links hebben een beschrijvende linktekst en navigeren ergens naar toe</li><li>Knoppen hebben een tekst die beschrijft wat er gebeurt als je er op klikt</li><li>Invoervelden hebben een zichtbaar label dat vertelt wat je in het veld moet invullen</li><li>De taal van je website is toegevoegd</li><li>De focus aanwijzer is altijd zichtbaar voor toetsenbordnavigatie</li></ol><p>Marloes Bosch is frontend specialist bij LimoenGroen en expert in digitale toegankelijkheid. LimoenGroen maakt websites en digitale toepassingen die iedereen kan gebruiken, ongeacht lichamelijke of technische beperking. Wil je weten hoe de digitale toegankelijkheid van jouw website kan worden verbeterd? Stuur een bericht en we praten je graag vrijblijvend bij. Je kunt Marloes mailen op <a href="/service/mailto:marloes@limoengroen.nl">marloes@limoengroen.nl</a>.</p><figure><img alt="Een roze aanwijzingsbordje in het gras met een pijl naar het rolstoelpad." src="https://cdn-images-1.medium.com/max/1024/1*NT6yu43bcDHelf0a-2xcDQ.jpeg" /><figcaption>Foto van <a href="https://unsplash.com/@yomex4life">Yomex Owo</a> op <a href="https://unsplash.com/photos/gRTzhQsiVG0">Unsplash</a>.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2fa0f52dd44" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/digitale-toegankelijkheid-de-7-meest-gemaakte-fouten-d2fa0f52dd44">Digitale toegankelijkheid: de 7 meest gemaakte fouten</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zes front-end ontwikkelingen in Drupal]]></title>
            <link>https://medium.com/limoengroen/zes-front-end-ontwikkelingen-in-drupal-c558294f9b63?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/c558294f9b63</guid>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[css-houdini]]></category>
            <category><![CDATA[decoupling]]></category>
            <dc:creator><![CDATA[Marloes Bosch]]></dc:creator>
            <pubDate>Mon, 04 Nov 2019 13:58:35 GMT</pubDate>
            <atom:updated>2019-11-05T08:12:34.337Z</atom:updated>
            <content:encoded><![CDATA[<p>Van 28 t/m 31 oktober vond DrupalCon Amsterdam 2019 plaats in de RAI. 1500 ontwikkelaars, project managers en gebruikers kwamen naar deze Drupal conferentie om te netwerken, kennis te delen en samen te werken aan Drupal. LimoenGroen was erbij en heeft veel waargenomen, bijgedragen en geleerd. In onze blogpost serie lees je de laatste ontwikkelingen van Drupal.</p><p><em>Dit artikel is onderdeel van de </em><a href="https://medium.com/limoengroen/de-5-highlights-van-drupalcon-amsterdam-2019-14c9f7eae102"><em>blogpost serie over DrupalCon Amsterdam 2019</em></a><em>.</em></p><h3>SVG in Drupal</h3><p>SVG’s (<a href="https://developer.mozilla.org/nl/docs/Web/SVG">Scalable Vector Graphics</a>), worden steeds populairder. Ze zijn goed schaalbaar, onafhankelijk van de resolutie. Dit betekent dat SVG’s altijd scherp zijn, in tegenstelling tot bitmap afbeeldingen. Bovendien is de <a href="https://caniuse.com/#feat=mdn-svg_elements_svg">browser support</a> inmiddels erg goed.</p><p>SVG’s zijn opgebouwd met XML markup. Een groot voordeel van SVG’s is dat je ze styling mee kunt geven. Dit kan door middel van <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/style">inline styles</a> in de XML. Ook is het mogelijk om de SVG classes te geven, zodat je ze in CSS kunt manipuleren. Een ander voordeel van SVG’s is dat je ze kunt laten <a href="https://codepen.io/Aniboaz/pen/WpvpKO">animeren</a> en je kunt er <a href="https://codepen.io/dudleystorey/pen/QvvEYQ">tekst effecten</a> aan toevoegen. Zulke animaties kun je met CSS toevoegen. Een andere manier is om in de SVG markup zelf specifieke SVG animatie elementen toe te voegen. Voorbeelden daarvan zijn: <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animate">&lt;animate&gt;</a> en <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animateMotion">&lt;animateMotion&gt;</a>.</p><p>SVG’s hebben ook een nadeel. Ze bevatten (vaak) onnodig en ongewenste metadata, vooral na een export van een SVG uit editors (Sketch, Adobe Illustrator). Daarom is het belangrijk om de markup te bekijken en onnodige data te verwijderen.</p><p>Melinda Kovacs en Francisco Jose Seva Mora <a href="https://drupal.kuoni-congress.info/2019/program/abstract/175">presenteerden</a> de voors en tegens op DrupalCon Amsterdam 2019.</p><h3>Layout Builder Ecosystem</h3><p>Met de Drupal Layout Builder kunnen redacties snel en gemakkelijk visuele layouts maken en beheren. Zowel templates als landing pages kunnen met drag-and-drop snel in elkaar worden gezet en worden aangepast. De open source ontwikkelgemeenschap heeft een reeks aanvullende modules gemaakt die de functionaliteit van Layout Builders fors uitbreiden. Dit zijn ze:</p><ul><li>Layout Builder Asymmetric Translations: Vertalen van layouts</li><li>Layout Builder Symmetric Translations: Vertalen van blokken in een layouts.</li><li>Layout Builder Modal: Off-canvas dialog (Configuratie) in een modal</li><li>Layout Builder Restriction en Block Blacklist: Beperkt het aantal layouts (bijv. per inhoudstype) en blokken waar een gebruiker uit kan kiezen.</li><li>Layout Builder Styles: Hiermee kunnen gebruikers eenvoudig (voorgedefinieerde) CSS-classes aan een layout toevoegen.</li><li>Layout Builder Library: Hiermee kunnen voorgedefinieerde sets van layouts worden samengesteld, een Library, waar de redactie uit kan kiezen.</li><li>Menu Item Extras: In combinatie met Layout Builder kunnen layouts in Extra Menu’s worden toegepast.</li><li>Mini layouts: Maakt geneste layouts mogelijk, vergelijkbaar met Mini Panels-module.</li><li>Paragraphs Blocks: Individuele Paragraphs, die in de content gebruikt worden, kunnen hiermee in een layout worden geplaatst.</li></ul><p>Dank aan de Layout builder ecosystem <a href="https://drupal.kuoni-congress.info/2019/program/abstract/402">presentatie</a> van Boyan Borisov op DrupalCon Amsterdam 2019.</p><h3>CSS Houdini</h3><p>CSS Houdini is al enige tijd in ontwikkeling. Houdini maakt het mogelijk om custom CSS properties en property values te schrijven die nog niet bestaan. Een zelfgeschreven property werkt, mits goed geschreven, in alle browsers. Dat maakt het ook bijzonder, omdat ontwikkelaars nu moeten wachten tot alle browsers een nieuwe officiële properties hebben geïmplementeerd. Met Houdini is dit niet meer het geval, omdat alle browsers hun API’s openstellen en ontwikkelaars dus direct gebruik kunnen maken van de tools die een browser onder de motorkap heeft. Het is net zoiets als naar Ikea gaan en hen vertellen dat je een nieuw product wilt, samengesteld van materialen die ze al hebben en gemaakt wordt met hun eigen machines.</p><p>In theorie had hiermee display: flex; al gebruikt kunnen worden, lang voordat het een officiële property value werd. Houdini breidt CSS uit d.m.v. javascript. Het werkt beter dan polyfills, omdat Houdini op het juiste moment in het render process ingrijpt. Polyfills doen dit minder efficiënt.</p><p>Nog niet alle API’s zijn beschikbaar, maar met een aantal kan al getest worden: <a href="https://ishoudinireadyyet.com/">ishoudinireadyyet.com</a> . Enkele voorbeelden van wat er mogelijk is zie je op <a href="https://css-houdini.rocks/">css-houdini.rocks</a>. Bekijk de track hierover op DrupalCon Amsterdam 2019: <a href="https://www.youtube.com/watch?v=QV3B9CCCNXU&amp;list=PLpeDXSh4nHjSZET8xL2RyK3_2WeXxyWkY&amp;index=28">Houdini — New Era of CSS</a> van Vidit Anjaria en Saket Kumar.</p><h3>Progressive decoupling</h3><p>Vue.js is een Javascript framework waarmee je interfaces en applicaties met een pagina kan bouwen. Een Brits bedrijf uit Manchester heeft Vue.js (uitspraak: “view”) gebruikt om een betere gebruikerservaring te realiseren bij het doorzoeken van alle varianten van opleidingen op een Briste universtiteit, door de site “progressively decoupled” op te zetten. In plaats van per variant een node te gebruiken is er slechts 1 node per opleiding en zijn alle varianten als paragraphs in die node opgenomen. Drupal rendert de node, waarbij in de Twig template vue attributen zijn opgenomen en variantdata via drupalSettings in de output wordt gezet zodat Vue clientside de dynamische onderdelen van de pagina toont of verbergt.</p><p>Men heeft ervoor gekozen om de data niet via een webservice aan Vue aan te bieden, maar via drupalSettings, omdat dat voorkomt dat er extra requests nodig zijn tijdens het bekijken van de pagina. De footprint van Vue.js in deze opzet is gelijk aan die van jQuery. Beiden kunnen prima naast elkaar bestaan en gebruikt worden.</p><p>Voordelen van Vue.js zijn:</p><ul><li>Het is een goed begin voor nieuwe ontwikkelaars en het is niet zwaar</li><li>De documentatie is duidelijk</li><li>Vue.js heeft een actieve community waar je altijd hulp kan vragen</li><li>Presteert hoog door de tweerichtings gegevensbinding en virtuele DOM, net zoals in Angular en React</li></ul><p>De learning curve van Vue.js is lager dan bij andere frameworks en kan vrij gemakkelijk worden toegevoegd aan een bestaande site. Voor het build proces is het ook niet meer nodig om: npm, Grunt, Gulp, Webpack, Parcel etc. te doen. Een script-tag is genoeg om de builden in Vue.</p><p>Meer learnings en tips vind je in de opname <a href="https://www.youtube.com/watch?v=TBLlwvM_uPc&amp;list=PLpeDXSh4nHjSZET8xL2RyK3_2WeXxyWkY&amp;index=18">Progressive decoupling in action: using Vue.js to add rich application-like functionality</a> van Phil Wolstenholme in de DrupalCon Amsterdam 2019 playlist.</p><h3>Front-end beveiliging</h3><p>Beveiliging in de front-end bestaat, ondanks dat men dat niet denkt. Enkele manieren waarbij misbruik kan worden gemaakt in de front-end zijn SQL injecties en cross-site scripting. SQL Injecties kunnen op verschillende manieren worden gedaan zoals de input veranderen of iets in de database veranderen. Via cross-site scripting kan iemand inloggen met jouw naam en je wachtwoord veranderen.</p><p>Vijf tips om de veiligheid in front-end te vergroten:</p><ol><li>Profielfoto’s moet private zijn.</li><li>Filter de inputvelden.</li><li>Gebruik Drupal modules voor het beheren van wachtwoorden.</li><li>Gebruik Drupal’s Form API om formulieren te maken.</li><li>Blokkeer cross-site functies.</li></ol><p>Meer tips zie je in de presentatie van Madalina Cotumbeanu <a href="https://www.youtube.com/watch?v=VsOFvJdHeKI&amp;list=PLpeDXSh4nHjSZET8xL2RyK3_2WeXxyWkY&amp;index=12">Frontend Security is a Thing</a> in de playlist van DrupalCon Amsterdam 2019.</p><h3>Themes en templates in Drupal 9</h3><p>In Drupal 8 werden de <a href="https://www.drupal.org/docs/8/theming/twig">Twig templates</a> geïntroduceerd om de Drupal front-end op te bouwen. Dit veranderde de theme laag van Drupal compleet. Een groot voordeel ervan is dat het als front-end ontwikkelaar veel eenvoudiger is om de HTML output te beïnvloeden. Desondanks blijft de theme-laag lastig in gebruik, zeker voor nieuwkomers.</p><p>Wat het zo lastig maakt, is de ‘inheritance’ van verschillende thema’s die op elkaar bouwen. <a href="https://www.drupal.org/docs/8/core/themes/bartik-theme">Bartik</a> bijvoorbeeld, het default thema van Drupal, gebruikt <a href="https://www.drupal.org/docs/8/core/themes/classy-theme">Classy</a> als basis thema. Classy is weer afhankelijk van het <a href="https://www.drupal.org/docs/8/core/themes/stable-theme">Stable</a> thema. Dit maakt het Bartik thema al drie lagen diep en staan alle bijbehorende bestanden dus in drie verschillende thema’s. Deze diepe gelaagdheid heeft ook als consequentie dat als Twig templates/CSS/JS niet op de juiste manier zijn overschreven in de hoogste laag van het actieve thema, het gemakkelijk is om de front-end ongewenst te beïnvloeden bij een update in één van de onderliggende lagen. Bijvoorbeeld: het field Twig template is overschreven in de hoogste laag, maar de bijbehorende CSS niet. Er vindt een CSS update plaats in een andere (lagere) laag, die door wijzigingen in het overschreven field template in de hoogste laag niet meer goed wordt toegepast. Hierdoor is er een groot risico dat de styling kapot gaat.</p><p>Om dit te voorkomen kun je gebruik maken van een <a href="https://www.drupal.org/project/drupal/issues/3050384">starterkit</a> in plaats van een basisthema om de afhankelijke gelaagdheid te verminderen. Dit maakt het mogelijk om Classy te verbeteren, zonder dat het invloed heeft op het actieve thema.</p><p>De hele track <a href="https://www.youtube.com/watch?v=rBZaKXYG79c&amp;list=PLpeDXSh4nHjSZET8xL2RyK3_2WeXxyWkY&amp;index=11">Next steps on modernizing the Drupal theme system (Drupal 9 and beyond)</a> van Lauri Eskola is een aanrader wat ons betreft.</p><p><em>Dirk, Martijn, Marloes, Joyce, Erik, Irfaan en Martijn, developers bij LimoenGroen, schreven deze blogpost over front-end ontwikkelingen in Drupal 8 en 9. Wil je meer weten over hoe wij omgaan met decoupled en andere front-end ontwikkelingen en hoe dit kan bijdragen aan het behalen van business doelstellingen? </em><a href="/service/mailto:hallo@limoengroen.nl"><em>Stuur ons een berichtje</em></a><em> of </em><a href="https://www.limoengroen.nl/contact"><em>kom eens langs</em></a><em> bij ons op kantoor. We praten je graag bij.</em></p><figure><img alt="Sean Blommaert presenteert de Roadmap van het Media initatief." src="https://cdn-images-1.medium.com/max/1024/1*cQakPG-wP-Te4ZyYIpBpjw.jpeg" /><figcaption>Foto door <a href="https://www.flickr.com/photos/illek/48975303011/in/photolist-2hBKnwc-2hBNbzp-2hBKnu8-2hBNbv6-2hBKnpZ-2hBKn6n-2hBKmXg-2hBP6BN-2hBKmLe-2hBKmHd-2hBMfDD-2hBNaJn-2hBNaDN-2hBMezQ-2hBMej4-2hBN8f4-2hBMcHi-2hBN7R8-2hBJnx6-2hBMbnn-2hBJnit-2hBMbch-2hBN5XU-2hBJ34S-2hBJ31L-2hBLQHC-2hBJ2WT-2hBML4X-2hBJ2PP-2hBML1R-2hBJ2KL-2hBMKXu-2hBMKVq-2hBLQnc-2hBMKRc-2hBJ2zL-2hBJ2wQ-2hBLQaU-2hBLQ91-2hBJ2rj-2hBMKDo-2hBJ2pR-2hBLQ4G-2hBJ2kY-2hBMKyP-2hBJ2hM-2hBJ2h1-2hBJ2fh-2hBJ2dZ-2hBMKqx">Illek Peter</a> (CC BY-SA 2.0)</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c558294f9b63" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/zes-front-end-ontwikkelingen-in-drupal-c558294f9b63">Zes front-end ontwikkelingen in Drupal</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drupal SEO-valkuilen]]></title>
            <link>https://medium.com/limoengroen/drupal-seo-valkuilen-c5a52090768b?source=rss----a485923d164a---4</link>
            <guid isPermaLink="false">https://medium.com/p/c5a52090768b</guid>
            <category><![CDATA[drupalcon]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[drupal]]></category>
            <dc:creator><![CDATA[Erik Stielstra]]></dc:creator>
            <pubDate>Mon, 04 Nov 2019 13:48:26 GMT</pubDate>
            <atom:updated>2019-11-04T13:48:26.346Z</atom:updated>
            <content:encoded><![CDATA[<p>Van 28 t/m 31 oktober vond DrupalCon Amsterdam 2019 plaats in de RAI. 1500 ontwikkelaars, project managers en gebruikers kwamen naar deze Drupal conferentie om te netwerken, kennis te delen en samen te werken aan Drupal. LimoenGroen was erbij en heeft veel waargenomen, bijgedragen en geleerd. Deze post van Erik over SEO valkuilen is onderdeel van onze <a href="https://medium.com/limoengroen/de-5-highlights-van-drupalcon-amsterdam-2019-14c9f7eae102">blogpost serie over DrupalCon Amsterdam 2019</a>.</p><figure><img alt="Drupal-ontwikkelaars aan het werk tijdens DrupalCon Amsterdam 2019" src="https://cdn-images-1.medium.com/max/1024/1*mL2Yo7Ykbr0c1C9a8ryP_A.jpeg" /><figcaption>Drupal-ontwikkelaars aan het werk tijdens DrupalCon Amsterdam 2019</figcaption></figure><p>Dit zijn 10 valkuilen bij het optimaliseren van Drupal voor zoekmachines:</p><ol><li>Voorkom indexeren van content die een eigen URL heeft, maar geen eigen pagina heeft. Bijvoorbeeld nodes die alleen als embedded content worden gebruikt. Oplossing: Gebruik de <a href="https://www.drupal.org/project/rabbit_hole">Rabbit hole-module</a> voor een omleiding of een 404.</li><li>Maak altijd pagina’s met behulp van een entity (bijv. node) als de redactie zelf pagina’s kan aanmaken met de Page Manager-module. Door een Node te gebruiken zijn Meta-tags standaard aanwezig.</li><li>Maak een zoekpagina niet indexeerbaar. Een wél indexeerbare zoekpagina zijn leidt tot een groot aantal indexeerbare pagina’s. Oplossingen: 1. Gebruik de <a href="https://www.drupal.org/project/metatag_views_overview">Metag Views-module</a> (alleen Drupal 7) en de configureer de zoek-View met <em>noindex</em>; 2. Gebruik een node als basis voor de pagina en configureer die met niet-indexeren.</li><li>Verberg de ontwikkel- en acceptatie-omgeving voor zoekmachines. Oplossing: Scherm deze omgevingen af met gebruikersnaam en wachtwoord.</li><li>Bewaar de assets die door robots.txt worden geblokkeerd (bijv afbeeldingen, icons, etc.) altijd in het publieke files-directory.</li><li>Verwijder ongebruikte modules uit de site; Deze vertragen een site. Gebruik de <a href="https://www.drupal.org/project/unused_modules">Unused modules-module</a> om mee te controleren.</li><li>Voorkom meerdere redirects, bijv. (<a href="http://www.example.com/">http://www.example.com</a> &gt; <a href="http://example.com/">http://example.com</a> &gt; <a href="https://example.com/">https://example.com</a>).</li><li>Sla bestanden die door bezoekers worden geüpload (bijvoorbeeld bij een contactformulier) op in een afgeschermd directory. File uploads die in het openbare directory worden weggeschreven kunnen door Google geïndexeerd worden. Dit kan manual action (punishment) door Google opleveren. Oplossing: Gebruik de <a href="https://www.drupal.org/project/captcha">Captcha-module</a> of <a href="https://www.drupal.org/project/simple_recaptcha">Simple Google Recapcha-module</a> (bij de laatste blijft de pagina-caching in tact).</li><li>Zorg er voor dat alle geïndexeerde content een beschijving heeft. Als een URL met <em>disallow</em> in robots.txt wordt opgenomen, wordt crawling voorkomen maar indexering blijft mogelijk en wordt niet ongedaan gemaakt. Indexering kan bijvoorbeeld plaatsvinden als de URL wordt gebruikt in een link op een wél bezochte pagina. De URL wordt nu wel in de zoekindex opgenomen, maar er is geen metadata (bijv. beschrijving) bekend.</li><li>Gebruik niet Google Analytics én Google Tag Manager tegelijkertijd. Gebruik de een of de ander, beide is slecht voor performance.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5a52090768b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/limoengroen/drupal-seo-valkuilen-c5a52090768b">Drupal SEO-valkuilen</a> was originally published in <a href="https://medium.com/limoengroen">LimoenGroen</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>