For The Brain
/
Website design and development
/

6 Infrastructure Best Practices for WordPress

6 Infrastructure Best Practices for WordPress

Anddy Ferreira

May 15, 2023

If you are new to WordPress, you may find the open-source software experience to be too open. WordPress can be hard to digest for first-timers, and even experienced WordPress developers can make fundamental mistakes while building sites for clients (or themselves).

So how do you build a WordPress website that is reliable, scalable, and usable? While there’s no definitive right way to develop a site, there are best practices you can follow. This series explores best practices for 5 interrelated WordPress areas:

  1. Infrastructure
  2. Code reliability 
  3. Plugins 
  4. Optimization
  5. Accessibility 

Understanding these best practices will give you a better understanding of how to assemble the necessary tools to create a pro-developer-grade WordPress that’s functional, structurally sound, fast, and accessible to all. 

Let’s begin at the beginning: Infrastructure Best Practices for WordPress.

Infrastructure is our foundation. Even before you start building your site on WordPress, it’s critical to anticipate infrastructural architecture. What type of website are you building? Whether it’s an ecommerce site, podcast homepage, or personal portfolio, the type of website determines the level of structure. For example: a blog will not have the same level of complexity as an ecommerce site.

WordPress is free, but as any developer knows, setting up – and reconfiguring– architecture is time-consuming and expensive. What I mean is: get it right the first time!

Web browser communicating between domain provider and web hosting server

1. Separate Your Domain and Hosting Services

Ideally, domain and hosting services should be separate to minimize performance risks. For sites that you expect to scale up significantly, it is crucial to choose a hosting plan that can support your site now and in the future. Never go for the first offer when it comes to hosting providers. Be a professional, do your due diligence, and compare pricing and benefits from different hosting providers.

Once you have the right provider, the next priority is web hosting security. An SSL certificate is an absolute must — it provides site protection against security risks and gives users more trust in your site.

2. Choose A Database

MySQL database dashboard

WordPress Database is the heart of the operation, containing all the necessary information needed to run your site. MySQL is the main database provider known for working well with open source tools like WordPress. Always keep the database secure with the hosting provider.

3. Test code on the development environment before pushing live

Local development terminal

As a developer, it is common practice to have two environments: one for development and one for production. Before pushing code to a “live” (production) site, you’ll want to confirm the code is working properly by testing in the development environment. The development environment gives you a way to build and experiment without causing errors or inconsistencies on your live WordPress site. 

There are two basic options for development environments: working locally or using a development platform2. Each has upsides and downsides. 

Local development provides a developer with more control. But, local servers are not connected to the internet, so there can be no in-depth analysis of the site’s “live” performance. 

Development platforms can provide developers with great details about server performance and integrate with coding tools like GitHub. Remote developers can work together in real time with robust version control. 

However, there are limitations. For instance, developers aren’t fully in control of their environment: many features within the platform will be hiding behind a pricing plan. Eventually, you’ll need to pay to scale or unlock a tool you need unlike in local development, which is usually free. 

Both methods can build great websites, so choose whichever works best for you.

Installing WordPress

Installation screen for WordPress

Once you are ready, WordPress3 can be installed. 

Remember, there are two ways to install WordPress. The best option is having the hosting provider install it — providers like Bluehost will install WordPress for you, saving you the heavy lifting. However, not all hosting providers offer this service. To do it manually, download the WordPress folder from WordPress.org and follow their detailed instructions. You’ll need your SQL database information, so keep that information handy during installation.

And a reminder: when WordPress is installed and the database is set up properly, that database cannot be altered or updated in any way. 

Manipulating a database from MySQL can potentially lead to a critical error on the site. It's important to backup4 your database on a regular basis.

4. Set up a WordPress theme

WordPress themes give you the general design of your website, often including a full site design architecture.

Page builders like Divi and Elementor allow users to create, edit, and customize website layouts without having to write code.  

Custom sites will require a custom WordPress theme using advanced custom fields (ACF). Using custom fields is very development-heavy — all hand-coded — and will be discussed in a future post. Because it involves custom code, building a site using ACF can  have more risks and more complications.   

Especially for ACF themes, we should always use a child theme5. Think of the child theme as a safety measure: it allows us to modify the parent theme without losing customizations. If the child theme code creates an error, we can revert back to the original parent theme. 

WordPress dashboard with appearance selected and WordPress themes displayed

5. Add a Compression Boilerplate

Once the theme is selected, adding a compression6 boilerplate for the theme’s codebase will significantly enhance performance. The boilerplate will improve optimization and be the foundation for a scalable site. The compression build will reduce CSS and JS file size, effectively “minify-ing” them without the need for extraneous plugins. 

Remember what we said about thinking ahead? A site can reach a threshold at any point —  you’ll be glad you spent the time to build a well-thought-out and structural codebase. 

6. Organizing your file structure

Theme structures may be different, but almost all WordPress themes consist of the files below:

We’re about to run into the most frustrating part of WordPress for devs: organization. WordPress allows developers to create custom files from scratch. This is a useful capability, but often leads to a situation where there are 100s of unorganized, badly-labeled php files. 

Inside a WordPress theme folder displaying the files within the theme

But, using the power of WordPress we can organize these files into folders, right?

Wrong. Unfortunately, WordPress has some restrictions when it comes to organizing files. It might make sense to a dev to put all pages into a big folder named “pages,” but WordPress will only recognize a specific range of folder names. It’s critical, at this point, to create the right folders for the right php files (or risk having a very broken site). 

Here’s WordPress’s folder naming conventions: 

A well-structured WordPress theme folder

Check back for more WordPress

Great work. Now, are you ready to get that php code in its most optimized form? We’re excited too, but we’ll have to wait for the next post! Boom, cliffhanger. 

In the next post of this series, we’ll dive deep into Code Reliability and how to make your current WordPress site codebase into an unstoppable, stabilized powerhouse.

Footnotes

1 Local WordPress setup

2 Pantheon setup

3 WordPress guide to installation.

4 WordPress backup plugin that allows users to migrate WP site to another site. Also, allows WP site to be backed up.

5 Child theme setup guide.

6 Helper guide to setup gulp into WordPress development kit. (Webpack can be setup as well)

Let’s
Connect!

We love meeting more Good People that are as passionate as we are. Give us a shout if you want to connect and learn more about ML.