Replace media files with respect to SEO: Media Entity File Replace Drupal module!

Feb 12, 2020
admin
Replace media files with respect to SEO in Drupal

If your website has plenty of media files (PDF presentations, price-lists, product images, etc.), you know how cumbersome it can be to replace them. Special attention in file replacement needs to be paid to SEO — because, as every SEO expert knows, every detail matters there.

Luckily, your Drupal 8 website offers more and more ways of easy media management that will also allow you to stay in line with the best practices of SEO.

Discover how to replace Drupal media files easily, with no fuss or extra manual efforts, and with your SEO rankings preserved. This is possible thanks to the new Drupal module — the Media Entity File Replace.

When do you need to Drupal replace media files?

The content never stays unchanged — it needs to keep up with the new business circumstances. Media files are not exception. For example, you may need to:

  • update a PDF presentation for your company/products/services
  • change your price-list
  • update your how-to checklist
  • upload new product images with better quality than before
  • make changes to your corporate video

and many other types of content.

What is the problem with the standard file replacement?

The standard procedure includes removing the old file and uploading another one. When it is replaced, your file gets a different name and path. Drupal appends a number to the end of the new one (_0, _1, etc.), instead of overwriting the original.

Standard file replacement in Drupal 8

File replacement becomes an especially tedious process when the file is used in multiple places throughout your website. This means additional expenses on your or your staff’s manual work. A special point of concern here is the impact on SEO. Read on to find out more about the impact of file replacing on your SEO.

How does media file replacement influence SEO?

File names play a part in your SEO rankings. Human-readable names enriched with keywords and written through a dash is a great way to tell Google what your image is about (in addition to the ALT tag), and this benefits your SEO.

Changing your file name and path can lead to a certain loss in SEO rankings because Google treats the newly uploaded files as new, and needs to recrawl, reprocess, and reindex them. This can take a long time during which it will show old and irrelevant content.

And, of course, if your files are used in content throughout your website and you change them but forget to re-upload them everywhere, they will be unavailable to your users. File path changes have the potential to cause broken links, which is one of the most annoying things both for search engines and users.

Never lose any SERP position to your competitors. Use helpful tools to replace files easily and without losing SEO.

How the Media Entity File Replace module can help

The new Media Entity File Replace module for Drupal 8 offers a smart and SEO-friendly way to replace Drupal media files. The module replaces the source files in Drupal media entities that have a file-based field. It does so by overwriting the old file with the new one. What’s even more important, the name and path are preserved in the process.

The Media Entity File Replace works with Media entities in Drupal 8. If you use the Media system to manage your media files, this module will suit you.

Note: To use the Media module, consider updating your Drupal website to the latest version where it has been greatly improved — our Drupal support team can do it for you.

Installing the Media Entity File Replace module

The module is installed like any other. It depends on a bunch of core modules: Media, File, Field, Image, User, and System.

Installing the Media Entity File Replace module in Drupal 8

Configuring the File Replace widget

The module comes with the File Replace widget, which you need to enable in the media types for which you want your files to be overwritable. Let us remind you: Drupal 8 has 5 default media types: Audio, Document, Image, Remote video, and Video, while others can be created to your liking.

To enable the File Replace widget, we need to go to Structure — Media types — {Our media type} — Manage form display. In our example, we work with the Document Media type.

Let’s drag the Replace File widget to the enabled ones. The perfect place is just below the File field.

Configuring the File Replace widget in Drupal 8

Replacing your Drupal media files

Let’s create a new document entity in Media — Add media — Document. We then upload an “Our services” PDF to it.

Creating a Drupal document Media entityDrupal media file path

The PDF is now saved in our Media Library (Content — Media) where we can go and edit the entity in order to replace the PDF.

Instead of the usual Remove button, we now see the Replace button. If the “Overwrite original filename” is checked, the original name will be kept and the content will be replaced.

Media Entity File Replace Drupal 8 module in action

We click “Choose file” and upload a new one — “Updated services.”

Replacing files with the Media Entity File Replace module

After saving, we see that the filename in this media entity is the same as before.

Drupal document file path

However, the content of the source file available by the same path has been rewritten. It now shows our updated services.

Media file replaced with its path inchanged in Drupal 8

This PDF can be used as an attachment in your content. You just need to add a Media field in your content type, and then you can easily fetch media there from the Media Library. Visit our “Media handling in Drupal 8” to learn how media can serve as building blocks for content.

Adding documents from Media Library to content

In this example, we added a “Document” Media field to the Basic page, and then created a content page with our PDF attached to it.

Content entity with a document Media field

Wherever else we add the file throughout your website, it is going to be rewritten automatically after a replacement, with no need to reupload.

While using the Media Entity File Replace module, special attention needs also to be paid to caching so your users are able to see the updated content sooner.

Entrust your media setup to our Drupal team

The Media capabilities and the ecosystem of Media Library management modules in Drupal 8 keep growing at amazing strides. It offers you more every day for managing your media effortlessly, with joy, and with no SEO losses.

Ask our Drupal support & maintenance team to configure the ideal media management processes on your Drupal 8 website!

Category
 Get new blog posts by email