Getting To Know the Upcoming WordPress 5.8 Template Editor

WordPress 5.8 is slated for release on July 20. In just over a month, many users will get their first taste of one of my favorite new features: template-editing mode.

The template editor is a new tool that allows end-users to create custom templates without ever leaving the post-editing screen. It exists as a stepping stone toward the eventual site editor, a feature that will hand over complete design control to those who want it.

The downside to the new feature in WordPress 5.8 is that users will not have access to their theme’s header, footer, sidebar, or other template parts. It is a blank slate in which they must put on their design caps to create the entire page.

With these limitations in place, what is the point of the template editor launching with WordPress 5.8?

Landing pages.

A blank slate is not always a bad thing. There is a reason all the best themes include page templates named Blank, Empty, Canvas, Open, or something similar. Sometimes users want control over the entirety of the page’s output. And WordPress 5.8 is bringing that capability to every WordPress user.

I have been editing templates for months now, but always in the context of a block theme. I have built both a photography portfolio and WordCamp landing page as part of the FSE Outreach Program. Despite some hiccups, it has been a worthwhile journey being involved as the feature has come to fruition. However, most of my testing was on top of the TT1 Blocks theme.

It was time to put it to a real-world test with themes that are actually in wide use.

Will It Work With My Theme?

The question many users will have on their minds will be: will this new template editor work with my theme? The answer is that it depends. Generally, yes, it will work to some degree. However, because older designs were not created with the template editor in mind, not all experiences will be the same.

I wanted to really put this theory of working with every theme to the test. So, I loaded up Twenty Fifteen, one of my favorite default themes from the past decade.

Perhaps I jumped too far back.

Screenshot of a landing page built with Twenty Fifteen.
Twenty Fifteen has a two-color background meant for sidebar and content.

The block editor did not exist back when Twenty Fifteen was built. Its use of a box-shadow technique on the page background meant the entire page had two colored columns running down it. The design team had to use some hacky methods for equal-height sidebar and content backgrounds. Ahhh…the good old days before developers had access to CSS flex-box and grid.

It is these sorts of problems that could limit some older themes. In the case of Twenty Fifteen, I could hide the background with a Group or Cover block over the top of it.

Users will likely get better results when using something more modern, at least a theme built during the block era. Even something as simple as wide-alignment support will change the WYSIWYG nature of the template editor. If a theme does not support the feature, the front end will not match the editor.

I jumped ahead a few years. Twenty Nineteen was the first default WordPress theme to support blocks. It is old but not ancient in internet years.

There are some differences between the editor and front-end views. The Cover block padding is off, the vertical spacing does not match, the search input’s font size is different, and the search button’s border radius is round on the front end. However, it is nearly a three-year-old theme now. It held up better than expected in this simple test.

Jumping ahead a couple of years, I activated Twenty Twenty-One, WordPress’s most recent default theme.

The editor is a pretty close approximation of what you see on the front end. The most noticeable differences are the inconsistent padding for the Cover block and the light gray border for the search input field in the editor view.

It was time to put the template editor to the “real” test. I activated the latest version of Eksell, one of the most well-rounded block themes in existence.

Obviously, the theme outputs a black section on the left. That is intended for the theme’s sidebar/menu flyout. However, because the user has no access to the template part that outputs that element, it may be impossible for some to create custom templates with this theme. I am sure that Anders Norén, the developer, will address this problem.

Similar, unknown issues will arise with the many thousands of themes in the wild. It does not mean a theme is necessarily bad. It just means it was not built with the template editor in mind. Users may need to throttle back their hopes a bit until they have thoroughly tested template-editing mode with their active theme.

Oh, and that ugly whitespace that shows the content background at the top of the editor? You will see that with literally every theme. I am clueless as to why the development team thought that it would make for a good default. Nearly every web design I have looked at over the years zeroes out the page’s <body> element padding.

For those theme authors who are reading, you will need to deal with this. If you have already been building for the block editor, you are likely a pro at handling such quirks.

If we look at a custom theme I have been building, you can see no alignment issues between the editor and front end.

The difference for my theme is that I am building when the template editor is already a part of the Gutenberg plugin. The others were all created earlier. It is not fair to compare them. However, users should know that older themes might not work well. They may need to wait for updates or try out a fresh design before taking advantage of template editing.

I also chose Twenty Nineteen, Twenty Twenty-One, and Eksell because they were designed by professionals in our industry and were released in the last few years. They each hold up well but have a few issues that would be trivial to fix.

All of this is to say that results may vary — wildly.

The Ideal Way To Use the Template Editor

My fear with the template editor is that users will begin mixing their content directly into the editor. It is an issue I brought up during round #7 of the FSE Outreach Program. Ultimately, it is a question about the boundary between content and template.

Traditionally, theme authors would build custom templates for their end-users to apply to their pages. Unless those users knew how to make direct code changes, they only selected the template and edited their own content via the editor. It was always clear where content editing ended and template editing began.

The new mode muddies the waters a bit. Because users have direct access to change the template from within the post/page editor itself, I have no doubt that many will create the entire page’s content from within the template editor.

Even I made the mistake of putting what would typically be content in my example templates above. This was purely for illustration.

There is nothing wrong with this if it the user’s intention. However, templates are generally meant for controlling the layout of the page. Things like the header, footer, and content wrapping element belong within it, while the content itself is stored separately. Templates are also meant to be reused. If you apply the same template to multiple pages, any changes made to that template will update every page.

My recommended starting point is to simply add the Post Content block to the template. You can do so from the block inserter or by pasting in this code snippet:

<!-- wp:post-content {"layout":{"inherit":true}} /-->

If you just want a blank/empty template, which is what the editor is good at right now, this is all you need. You can move back to the page editor and unleash your creativity.

Here is the start of a novelist landing page I built from this blank template:

Landing page for a novelist with featured hero section and latest books section.

The content of the page was added via the post editor rather than in template-editing mode. This will allow me to create multiple pages using the same open canvas.

If you want to add other layout elements, you can tack them on too. Try mixing and matching the Site Title, Site Tagline, and Navigation blocks as a header. Drop in a Columns block with other blocks to create a “widget area” in the footer.

The power of the template editor is coming with block themes. Eventually, designers will be able to pre-build these templates, and users will customize them. They will also have access to a more robust suite of blocks, such as loading up template parts. However, we have to wait until at least WordPress 5.9 later this year before they become available, and that is not set in stone yet.

Until then, we have a sort-of-OK-but-kind-of-amazing landing page creator.

Business Formation Study: How are Businesses in the US Structured?

There are approximately 100 billion decisions you have to make when starting a business.

Okay, maybe that’s a small exaggeration—but you know how many critical choices demand your attention as a business owner.

One of the earliest and most important decisions you’ll make is what type of business you want to create. I’m not talking about favoring online versus physical stores or selling products versus services; this is about the type of legal form your business should take.

This determines how you’re taxed, your personal liability, how you raise money, and what happens to your business should something happen to you, to list a few considerations.

That’s why we wanted to do a deep dive on business formations today. We want to take a look at how businesses are structured in the United States and what exactly that might mean for you as you get your business off the ground.

Let’s jump in.

Disclaimer: This study is based on U.S. business formations. Apologies to our international readers out there! But we think you’ll find the information here helpful especially if you conduct business with a U.S.-based client, partner, or vendor.

The 5 most common types of business structures in the US

There are many different types of business structures out there. However, we want to take a look at the five most common types, and what that might mean for you.

They are:

We’ll give you the pros and cons of the structure. We’ll also let you know who that specific structure might be good for.

Sole Proprietorships

Sole proprietorships are businesses that are owned and run by a single person. In a sole proprietorship, there is no legal difference between the business itself and its owner.

This is the most common way of organizing and forming a business, because it’s incredibly easy to establish and it doesn’t have to cost any money to do so. Freelancers, contractors, and “solopreneurs” often structure their business this way.

For tax purposes, all of the income, losses, and expenses you make from your business are a part of your personal income tax return. You need to report all of that to the IRS on Schedule C submitted via Form 1040.

The IRS taxes all of the profits made from business. Of course, you’re allowed to write off many expenses, including necessary purchases (e.g. office supplies), training (e.g. workshops, courses), and travel costs (e.g. flights, hotels, and conventions).

You won’t have to file a lot of documents. Depending on what service you’ll conduct, you might need to get a state or city license. And if you want to work under a fictitious name, you’ll need to register that with your state, county, or city you’re conducting business in (requirements vary depending on where you are). Other than that, though, you’ll be in the clear.

It’s also worth noting that sole proprietorships doesn’t limit your company to having just one employee. But it may require you to only use independent contractors and freelancers.

Pros

  • Easy to create. With other business formations, there will be more paperwork, fees, and headaches. With a sole proprietorship, though, you won’t have to file any documents with the government.
  • Taxes are simpler. Business formation types such as C corporations require you to file two separate forms of taxes: One for your business and another for your personal income tax. Sole proprietorships only require that the business owner file their personal income tax returns. Less work for you and your accountant—which is always a nice thing.
  • Cheap. This is easily the most inexpensive business formation on the list, since you’re not required to file any documents unless you’re working under a fictitious name. In that case you’ll need to register a Doing Business As (DBA) with your local government. This is considered your “trade name.”

Cons

  • Liability. As a sole proprietor, you’ll be personally liable for your entire business. This encompasses a number of potentially negative things such as debts or legal issues you run into while conducting your business. If you’re sued and you lose, you alone are responsible for the damages. If we had to point to the biggest downside of being a sole proprietor, this would be it.
  • Continuity of business. Since you’ll be your own business as a sole proprietor, this also means that your business ends if something should happen to you (e.g. death, injury, incapacitation).
  • No outside investors. Sole proprietors are not allowed to accept capital and funding from outside investors. That’s less money you could use to hire employees, create products and services, and generally grow your business.
  • Can’t issue equity. Some businesses are able to issue stock options to stakeholders and employees. Sole proprietorships cannot.

Who is this good for?

Sole proprietorships are great for freelancers, consultants, and other one-person operations. It allows you to get started with your business quickly and with little cost.

If you’re looking to seek funding, however, this would not be a good choice.

Limited Liability Company (LLC)

LLCs are a very common type of business in the United States,and for good reason. Unlike a sole proprietorship, LLCs are separate legal entities from business owners. This means individual owners won’t be liable for any debts and legal issues that might arise as they run their business.

For example, if your business gets sued for millions of dollars and you lose, you won’t have to worry about your personal assets like your house, car, and savings account being seized.

It also means that the company can have several owners (also called “members”). The IRS has rules about the type of business you’re allowed to run since businesses like banks and insurance companies are not allowed to be LLCs.

There is no maximum number of owners an LLC can have either. However, many states offer something called a “single-member LLC” (SMLLC) for an LLC with just one member. So it offers you more liability protection than a sole proprietorship, but you still just have one owner.

The way LLCs are taxed depends on whether or not the owners want to enter into a proprietorship, partnership, or a corporation. Partnerships need to file a partnership tax return and corporations need to file as C or S corporations (we’ll get into that later on).

Pros

  • Limited liability. You get limited protection from legal issues or debt that your business might incur. Note: That’s limited protection. It doesn’t cover everything (as we go over in the cons).
  • Tax flexibility. As an LLC, you’ll be able to choose whether you’re taxed as a proprietorship, partnership, or corporation. All have their benefits and drawbacks, but the flexibility is very helpful when making your decision.
  • Unlimited shareholders. You can offer stock options as an LLC to employees, investors, or stakeholders.

Cons

  • Limited liability is … limited. If you don’t completely separate your personal and business expenses, you stand the chance of running into legal issues. For example, a judge can rule that your LLC doesn’t fully protect certain assets if you don’t make sure to clearly separate the two worlds. Failure to do so could cost you … well, everything.
  • Fees, fees, and more fees. With a sole proprietorship, there are few fees if any. However, with an LLC, initial filing fees can vary anywhere from $45 to $500 depending on your state. Plus there are annual filing fees. One catch here though is that you can create an LLC in a state where you don’t live (e.g. a state with lower fees).
  • Taxes. Proprietors and partnerships are required to pay self-employment taxes up to 7.5% on their share of the profits. S and C corporations don’t have to do this, but they do have to pay taxes up to 7.5% on their salaries.

Who is this good for?

LLCs are good for small businesses that anticipate having some degree of liability and multiple owners and/or employees. It’s a fairly easy process to set up your LLC. Plus, the benefits you have when it comes to tax flexibility and stock options make it very lucrative.

Ultimately, this is an excellent choice for anyone burgeoning small-business owner who wants to establish a company that will remain relatively contained—but offers serious growth potential.

General Partnerships

Partnerships (or general partnerships) are business entities with at least two individuals.who are owners of the business. Like a sole proprietorship, it’s very easy to set up—however, it comes with even more liability since there are more owners.

The members share all profits, debt, and liabilities incurred by the business. This can be a double-edged sword. A rising tide raises all ships—so if your partner performs well, you and your business will benefit from it. However, if your partner doesn’t, then your business will suffer.

Also there’s more liability. Everyone in a general partnership has unlimited liability on the business’s debts and legal issues. If one partner is sued by a disgruntled client and loses, then all the other partner’s personal assets like their home and savings are at risk of being forfeited. Because of this, trust is absolutely paramount when it comes to creating a partnership. If you succeed, your partner succeeds and vice versa. However, if you or your partner fails, then you both will fail.

It should be noted that a subcategory of general partnerships are limited partnerships. These are typically composed of investors and other stakeholders who don’t have nearly as much liability as general partners.

There are also LImited Liability Partnerships, which protect the partners from each other’s potential misconduct. These are great for companies that have multiple professionals acting as a single entity (e.g. law firms).

Pros

  • No double taxation. General partnerships offer a very lucrative deal in terms of taxes. After all, you don’t have to pay taxes on the business’s profits. Individual partners do have to pay taxes for their personal income from the business. But the general partnership itself isn’t taxed.
  • Easy to start. General partnerships are incredibly easy to form. In fact, you can form one using just an oral agreement between partners. However, we highly recommend you draft a written contract for legal purposes. Contact an attorney to set up a partnership agreement to do so.
  • Less fees and paperwork. There are few to no fees incurred when creating a general partnership. There’s also less paperwork when it comes to this formation. As we mentioned, it can literally be formed through a handshake agreement (though we recommend you get it on paper).

Cons

  • More liability. In a general partnership, you’re not only liable to legal issues that arise with you but your partners’ as well. Depending on how many partners you have, the chances of you running into trouble only goes up. That can put your personal assets at risk.
  • No continuance. If one of the partners dies or is incapacitated then the partnership is dissolved—and with it, the business itself. This is also the case if one of the partners decides to withdraw from their partnership. If that happens, the entire partnership is dissolved.
  • Sharing debt. If one of the partners secures credit for the business, the rest of the partners share in that debt. This can create for some very sticky situations, especially if one of your partners gets credit without your knowledge.

Who is this good for?

This is an option for small businesses with few to no employees, but has two or more people who want to start a small business. Honestly, it’s not the best organizational structure out there and we’d recommend going with another option like forming a corporation, an LLP, or an LLC if you can.

C Corporations

C corporations or “C corps” are separate legal entities from the business owner. The C refers to how the entity is taxed, under subchapter C in U.S. internal revenue code.

This subchapter helps ensure that C corps have double taxation. That means that the corporation itself will be taxed on profits and then the shareholders will be taxed on their dividends.

The benefit, though, is that they offer a high degree of liability protection for their owners. After all, they’re a separate legal entity. That means if a disgruntled client sues your C corp, your personal assets are unlikely to be seized.

We mentioned before too that shareholders are taxed on dividends. This is because C corps can issue stocks (and therefore stock options) to shareholders.

All these benefits come with some catches though. For one, C corps are required to have a board of directors. These are designated officers who manage the business. The board of directors are also required to have an annual meeting where they elect their officers. If you’re the founder of a C corp, you must cede control and decision-making power to the board. If that’s an important element for you, definitely take it into consideration.

Pros

  • Little liability. The biggest boon of a C corporation is the fact that you’ll be protected from personal liability since it’s a separate legal entity. In fact, shareholders are typically only liable for any debt that might be incurred over the course of the business.
  • Attaining capital. If you’re looking to raise funding from outside investors, C corporations are the way to do it. In fact, venture capitalists typically only fund C corporations. Why is that? Honestly, it’s because your business will have “corporation” as a part of its name. Seriously. VCs are weird.
  • Continuance. If something terrible should happen to you or a founder of your business, the C corporation lives on and the work will continue. That means everyone who relies on the income brought in by the business can continue to rely on it.

Cons

  • Double taxation. C corps are taxed twice. Once on the profits, and once again on the shareholder dividends.
  • Fees, fees, and more fees. You’re going to have to pay filing fees each year in order to keep your corporation registered. You’ll also have to pony up a one-time registration fee.
  • A lot of formalities. C corporations are required to perform a bunch of little (and, frankly, annoying) formalities such as forming a board of directors, holding annual meetings, adopting bylaws, and more. This can distract from the tasks you want to devote most of your time and energy to.

Who is this good for?

If you’re planning on going public, a C corp is a great way to structure your business formally. It also helps that you have a lot more liability protection since your business will be a separate legal entity from you.

It’s also a good option if you’re seeking funding from venture capitalists. They tend to favor corporations more than other entities because of how legitimate it sounds (I’m being completely serious; VCs are weird folks).

S corporations

S corporations are another type of corporation (and also water is wet!). Just like the previous category, the S refers to subchapter S in the IRS tax code.

S corporations are considered “pass-through entities.” That means they aren’t subject to double taxation, because shareholders report all of the corporate income, losses, and debt on their individual personal tax returns.

S corps are also notable because there are no “owners” of the businesses. Instead, there are those who own shares of stock in the business. You can have more influence over the company if you hold more stocks. However, shareholders aren’t typically the ones who run the company. Rather that’s up to the board of directors (remember them from C corporations?).

Like C corps, S corps are also required to have a board of directors elected by an annual shareholders meeting. The ones elected to the board will be the ones running the day-to-day operations.

The directors in the board also elect the officers (president, VP, treasurer, and secretary usually).

Pros

  • Pass-through entity. As an S corp, you’ll be able to establish your business as a pass-through entity, which means you won’t experience double taxation. All profits and losses flow through the company and to the shareholders. This is especially lucrative if the company founders invested money into the business, since the losses can be written off in their tax returns.
  • Less liability. This is another aspect S corps share with their C corp siblings. Since the business is its own legal entity, shareholders are protected from personal liability. As such, there’s a barrier to their assets being seized in the chance there’s a bad court case.
  • Continuance. The transfer of ownership for an S corp is fairly simple. So you don’t have to worry about the business being dissolved or disorganized in the event or withdrawal.

Cons

  • Stricter rules. There are a lot of rules that come with creating an S corp. For one, you’re limited in the amount of shareholders—you’re allowed no more than 100. You also need to be a U.S. citizen/resident or be an estate or be a specific eligible trust to be a shareholder in an S corp.
  • A lot of formalities. Like C corps, you’re expected to have a bunch of formalities, such as the annual meeting of the shareholders and board of directors, as well as the adoption of bylaws.
    One class of stock. As an S corp, you’ll only be allowed to have one class of stock. You aren’t allowed to have both common and preferred stock. If you do so, you could have your S corp status revoked.
  • Fees, fees, and more fees. Like C corps, you’ll be expected to pay a stiff filing fee from $300 to $900 as well as various legal and accounting fees. That doesn’t even get into the annual upkeep fee you’ll have to pay.

Who is this good for?

Bigger businesses that want to be protected against personal liability and double taxation. Also, this is a fit for businesses who are or are expecting a steady amount of income. Those filing and legal fees aren’t going to pay for themselves.

How are businesses in the US Structured? Stats and Facts to know

Those are the five most common types of business formations and structures you’ll see in the United States.

Let’s now dive a little deeper under the surface to see what the numbers behind them look like. Below are a few stats and facts you should know when considering the type of business structure you want to form:

Fact #1: The most popular place to establish a corporation is…

Pop quiz: What state is the home to companies such as Citigroup, JPMorgan Chase, Morgan Stanley, and Goldman Sachs?

No it’s not Wall Street. It’s not even in New York City. They’re all actually based in Delaware—at least on paper.

In fact, they actually all share a single address: 1209 North Orange Street. That’s the home of the Corporation Trust Center in Wilmington, Delaware. Here’s what it looks like.

Source: Wikimedia
No, seriously. It’s true. That building that looks like a dentist’s office is actually the legal home of some of the wealthiest corporations in the world. Some 300,000 businesses are registered at the location. Other businesses “housed” there include Apple, General Motors, Google, and American Airlines.

The entire state of Delaware is home to more than 1.5 million business entities. That’s more than one business to every single resident who lives in the first state (pop. 950,000). In 2019 alone, more than 226,000 businesses were formed there. The most popular of those business structures were LLCs:

Source: DelawareInc
The reason that Delaware is so popular is because of a set of tax systems and laws that have made it incredibly business friendly (in a legal way!) since the late 18th century. For example, the Delaware Court of Chancery has literal centuries of legal precedent in settling corporate legal suits. They also allow businesses to settle legal disputes with just a judge instead of a jury.

There’s also the “Delaware Loophole,” which allows businesses to declare their revenue in Delaware rather than the state where they actually conduct business. This means they avoid their state’s taxes. It should also be mentioned that Delaware doesn’t tax on a number of different things, like corporate income.

Overall, if you really want to maximize your tax advantages and join a club made up of some of the most powerful corporations in the world, Delaware is your place.

Fact #2: Sole proprietorships are the most popular type of business formation (by a large margin)

Even though LLCs are the most popular type of business formations in the most popular state for Big Business, sole proprietors are the real majority in the United States.

As of 2016, there’s close to 26 million sole proprietors in the country alone, according to the IRS. As a comparison, in 2010 there were only 23 million sole proprietors. And the number increased a TON over the years prior to then (see chart below).

Source: Tax Foundation
Does this mean you should start a sole proprietorship? Not necessarily. But it does indicate that there are some clear advantages to having a sole proprietorship over an S corp, C corp, or partnership. For example, it’s incredibly easy to start up. There are also likely going to be more in the future with the rise of the gig economy (e.g. Lyft, Uber, Postmates)

Fact #3: C corps are less and less popular each year

You can also see in the chart above that S Corps and partnerships come in second while C corporations fall in third. In fact, the number of C corps seems to be dwindling by about 60,000 C corps each year.

Source: Tax Foundation
It doesn’t take an economist to figure out why, either. Pass-through entities. S corporations, partnerships, and sole proprietorships aren’t double taxed. Therefore, they’re seen as much more lucrative opportunities for business owners to maximize their profits.

It’s also an indicator of the wider range of economic issues business owners have faced in recent years. After all, since 2009 we’ve seen two different economic recessions and disasters that have absolutely hamstrung entrepreneurs’ ability to make money. It only makes sense, then, that they’ll pursue more lucrative options.

Fact #4: 2020 is a BOOM year for business applications

Did you think that a global pandemic ravaging the world would stop people from applying for businesses?

Well…yeah, I guess I did too. But apparently that’s not the case! In fact, more businesses are being applied for than ever in the United States. 2020 has been an absolute boom year for business applications, with nearly 160,000 businesses applied for since the year began.

Source: U.S. Census
It’s a massive increase of 38.5% compared to 2019.

Source: U.S. Census
Now the increase could be attributed to a few factors. For one, the stimulus bills passed by the U.S. government might have encouraged and incentivized a lot of people who otherwise wouldn’t have started businesses to do so.

Think about it. After you’ve been let go from your job due to the consequences of the pandemic, and the government hands you a $1,200 check, you might feel the urge to use your new time and money to start a business to get some income. Whatever the reasons, the surge of new businesses means that a post-pandemic economic boom is lying in wait.

Conclusion

There are many ways to start a business. However, the most popular way is easily sole proprietorships. Not only is it easy for you to start one but you don’t face the headaches that come with starting a corporation—such as legal and filing fees—as well as the tax disadvantages.

Whatever you ultimately choose, be sure to check back on Quick Sprout for more guidance and information on how to start your business.

MapLibre Project Gains Momentum with MapLibre GL Native Release

The MapLibre project is picking up speed with the release of MapLibre GL Native, an open source mobile SDK for Android and iOS. As anticipated, MapTiler’s fork of Mapbox’s mobile map SDKs are coming under the MapLibre umbrella. This free library enables developers to write native applications that can display vector maps on mobile devices, with advanced functionality like custom map styles and integrating specific business data.

The project was formed by Mapbox’s open source contributor community after the company announced that Mapbox GL JS version 2.0 would be released under a proprietary license. MapLibre GL founders include a diverse group of companies who are contributing to this healthy, community-led fork, including MapTiler, Elastic, StadiaMaps, Microsoft, Ceres Imaging, WhereGroup, Jawg, Stamen Design, and more.

MapLibre GL Native is developed and maintained as an independent mobile SDK, led by the MapTiler team in cooperation with Amazon, Facebook, Microsoft, and the MapLibre community. MapTiler forked Mapbox’s last version released under the OSS license in December 2020, and ensured that developers can migrate their apps with just a few lines of code. The release post identifies a few critical changes in the MapLibre SDK:

  • Tracking of end-users (telemetry) has been removed
  • OSS license: community ownership ensures it stays open-source forever
  • Updated distribution model: the library is now distributed via the Maven Central repository for Android and as a Swift package for iOS
  • Optional usage of authorization: access token requirement depended on the map provider and its policy

WordPress core doesn’t include a Map block but WordPress.com and Jetpack both use Mapbox GL JS 1.13.0. This is the last open source version before Mapbox updated to its proprietary license. I created a ticket to put it on the Jetpack team’s radar, and it looks like they may consider migrating to MapLibre in a future release. Plugin authors using Mapbox will also be at a crossroads when it comes time to update beyond version 1.13.0. MapLibre is the strongest alternative to Mapbox’s proprietary 2.x update. Migration instructions are available in the MapLibre GL readme file.

Using the `outline` Property as a Collapsable Border

The outline property in CSS draws a line around the outside of an element. This is quite similar to the border property, the main exception being that outline isn’t a part of the box model. It is often used for highlighting elements, for example, the :focus style.

In this article, let’s put a point on it, leaning into what outline is good at:

  1. They can be collapsed with each other (trickery!) because they technically “take up no space.”
  2. Showing and hiding outlines, or changing outline-width, doesn’t trigger layouts (which is good for performant animations and transitions).

Easier faux-table cell borders

Below is an example of a list that is laid out as a grid, making it look a bit like a table layout. Every cell has a minimum width, and will grow/shrink as the container becomes wider/narrower.

We could use border to pull this off, like this:

But in order to make an even border around each cell — never doubling up or missing — it’s a cumbersome process. Above, I used a border on all sides of each “cell” then negative margins to overlap them and prevent doubling. That meant clipping off the border on two sides, so the borders had to be re-applied there on the parent. Too much fiddly work, if you ask me.

Even having to hide the overflow is a big ask, which you have to do because, otherwise, you’ll trigger scrollbars unless you resort to even thicker trickery, like using absolutely-positioned pseudo elements.

Showing a flat table with seven columns and four rows, each cell numbered sequentially, 1 through 28. The table has a white background and block text and the borders are black around each cell with ample padding.

Check out the same result, visually, only using outline instead:

The code here is much cleaner. There is no real trickery at play. Each “cell” just has an outline around it, and that’s it.

Border in animation

Changing border-width will always trigger layout, no matter if it is actually needed.

Showing the paint rendering results from a performance test where a layout change is shown in the middle of the results taking 58.4 milliseconds to complete.

In addition, due to Chrome’s special handling of sub-pixels for border widths, animating the border-width property makes the entire border shake (which I think is strange). Firefox doesn’t have this issue.

Showing another performance test, this time with no layout triggered in the results.

There are pros and cons when it comes to animating borders. Check out Stephen Shaw’s post from a while back for an example of the performance implications.

There are some gotchas

Of course there are. Like most other CSS properties, there are a few “gotchas” or things to know when working with the outline property:

  1. Rounded outlines are only supported in Firefox at the time of writing. I imagine other browsers will eventually support them as well.
  2. An outline always goes around all the sides. That is to say it’s not a shorthand property like, say, border; so no outline-bottom, and so on.

But we can work around these limitations! For example, we can use add a box-shadow with no blur radius as an alternative. But remember: box-shadow has a higher performance cost than using either outline and border.

That’s it!

Will you always be working on something that calls for faking a table with an unordered list? Unlikely. But the fact that we can use outline and its lack of participation in the box model makes it interesting, particularly as a border alternative in some cases.

Maybe something like this tic-tac-toe board Chris put together several years ago could benefit from outline, instead of resorting to individually-crafted cell borders. Challenge accepted, Mr. Coyier? 😉


The post Using the `outline` Property as a Collapsable Border appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

W3C Announces Web Audio API Standard

The World Wide Web Consortium (W3C), an international standards organization that manages internet protocols, has announced that the Web Audio API is now an official standard. This designation signifies that W3C has vetted the technology in an industry-inclusive manner that is intended to accelerate adoption. 

A Detailed &amp; Comprehensive Guide to Disaggregated Storage

An Overview of Disaggregated Storage

Infrastructure disaggregation allows organizations to use computing resources more effectively by enabling scalability and flexibility. Disaggregation involves decoupling data center resources of memory, compute and storage, so that each resource can be scaled and provisioned independently. Disaggregation is already widely adopted in cloud computing platforms, with various clouds offering storage systems that are completely independent of compute instances.

Disaggregated storage is a version of composable disaggregated infrastructure that offers scalable storage by connecting various physical storage devices over a network fabric to form a logical storage pool, in some cases on demand. Disaggregated storage enables the creation of dynamic environments where the compute and storage resources scale elastically based on the application’s workload. Separating storage and compute instances also means that storage can be scaled and managed without interfering with the availability of an application’s services. 

How to Set up Employee Benefits

No matter the size of the company, one of the best ways to keep employees happy, loyal, and productive is through a great employee benefits package.

If employees have to jump through a complex series of hoops to gain access to their benefits, or if the benefit records are inaccurate, it’s frustrating for both sides. Having a clear setup process for your benefits program will alleviate this frustration by making sure everything is done correctly during the onboarding process.

Setting up and managing employee benefits programs becomes a far easier process when making use of HR software. The best HR software reduces paperwork and the chance for errors while allowing employees to have up-to-date information as they need it.

Three Benefits of Setting up Employee Benefits

Although it may seem like setting up employee benefits requires a lot of time and effort, it will be time well-spent. Additionally, there are a few benefits to managing the program through HR software, yielding desirable results down the road.

Reducing Chances of Errors

By automating the management of the employee benefits program through software, chances of mistakes diminish. By relying on software, rather than paper documents, fewer errors will occur.

Employees often can track the status of their own benefits through HR software. So should an error occur, the employee will be able to spot it quicker than someone in the HR department. Fixing these errors in a timely manner keeps employees happy and focused on their jobs, rather than worrying about benefits packages.

Saving Time

Setting up a software package to track benefits saves quite a bit of time for those in the company’s HR department.

HR department personnel will not have to manually enter data as frequently, which reduces the time required to manage benefits.

When employees can check on the status of their own benefits, they need less one-on-one help from the HR department. HR personnel won’t be answering all the same questions as often.

With a software package like Gusto, the software handles the termination of benefits when an employee leaves the organization. This saves quite a bit of time for HR personnel, while also ensuring a dismissed employee won’t continue receiving benefits inadvertently.

Adding a Benefit Company-Wide

When the company decides to add a new benefit for employees, such as a dental insurance plan or life insurance, employees appreciate it.

HR software simplifies this process. The software administrator can assign the new benefit to a group or to everyone, rather than going person by person.

Just add the benefit for the entire company, or for certain levels of employees, and the software takes care of the rest.

The Difficult Parts of Setting up Employee Benefits

Even with employee benefits software, setting up the benefits package does take some time. Here are some of the trickier parts of setting up these benefits.

Calculating the Cost of Benefits

Very few companies pay the entire cost of employee benefits. The company may expect the employee to contribute to the cost of health insurance for the employee and any dependents, for example.

It can be difficult to determine the exact amount that the company should make the employee contribute. The company doesn’t want to contribute so much that it becomes difficult to sustain the contribution in the future. Employees become unhappy and frustrated when the company must reduce or suspend benefits.

Along the same lines, making employees contribute an above-average percentage to their own benefits can leave the company uncompetitive in hiring situations.

Gusto can run scenarios for the company, helping to determine just the right amount to require employees to contribute.

Overwhelming HR Responsibilities

A large company may have a dedicated HR department, often with multiple employees. For a small business, though, the person running HR and overseeing the employee benefits programs may also have another job.

With Gusto, this employee will need less time to perform the HR work. This helps this employee dedicate more time for regular duties beyond HR work.

Additionally, the HR software simplifies the management of employee benefits programs. This means the person handling HR and another job doesn’t have to be an HR expert to be able to manage the program.

Helping Employees Understand Their Benefits

Explaining benefits to employees can be time-consuming for the HR department personnel. However, when employees have a better understanding of the benefits they’re receiving and the value, they’ll be happier and more likely to participate.

Within Gusto, administrators can post explanatory documents on the employee dashboard. These documents can explain the benefits for the employees, giving them access to the information whenever they need it. Consequently, employees will have fewer questions for the HR team.

Offering Personalized Benefits

In a growing organization, it’s possible to have employees in widely varying stages of life. Younger employees may not need life insurance benefits. Older employees may want health insurance for their entire families.

If the organization allows employees to pick and choose which benefits they want or the level at which they participate, this can be confusing to track.

HR software like Gusto simplifies the process of setting up a personalized benefits package for each employee.

Ensuring Fulfillment of Required Benefits

Government regulations require companies to offer certain benefits to employees who meet the criteria. Depending on the size of the company, some of these benefits could include:

  • Family medical leave
  • Health insurance
  • Time off for jury duty
  • Time off to vote
  • Time off for military service

Additionally, employers must pay unemployment insurance and workers’ compensation insurance on behalf of their employees without charging the employees. Employers must match the contributions of the employees for social security taxes and Medicare taxes.

HR software can ensure that the company follows the rules for all of these required benefits, preventing possible violations.

Step 1: View the Employer Dashboard

After signing up for the Gusto HR software, the HR administrator can use the Gusto dashboard. This shows all of the options for setting up and managing the employee benefits plan for the company. (In the examples going forward, we’ll use Gusto specifically to explain how the process works.)

View the Company Information for Benefits

The administrator of the HR benefits package can use the Gusto dashboard to view overall statistics and data regarding the company’s benefits offerings. Some of the information the administrator can view includes:

  • Percentage of Employees Enrolled: Through the dashboard, see how many employees participate in various portions of the company’s benefits plan. If one or two benefits have a low percentage of participation, these benefits may need tweaking.
  • Estimated Cost: Gusto will calculate the cost to the company for the employee benefits plan each month. It uses the number of employees enrolled and the amount of the company contribution to make the calculation in real time. As participation levels change, the calculation changes too, providing the most accurate information.
  • Invoices for Coverage: Gusto provides a means of managing the company’s benefit accounts, including automatic payroll deductions for employees. However, Gusto doesn’t make payments for services for the company. Administrators can use Gusto to view their invoices from a 401(k) plan provider or a health insurance plan provider. But they’ll need to send their payment for the invoices outside of the Gusto interface.
  • Corrections for Deductions: If the HR administrator ever notices a mistake in deductions for an employee’s benefits, Gusto allows for corrections. The administrator can spread these correction amounts over multiple payroll periods, so the employee doesn’t have a significant pay drop in any one pay period after the correction.

View the Employee-Facing Information for Benefits

Some of the information an HR administrator can upload to the Gusto dashboard that employees can see and use includes:

  • Employee Costs: Companies can give employees the ability to see their projected monthly contributions for benefits. This may include the amount the employee will pay for various levels of health insurance premiums or dental insurance, for example.
  • Contribution Percentage: Create a list of contributions that the company will make for employee benefits, so employees can see their remaining responsibility. Contributions the companies may make include a portion of health insurance premiums, a portion of dental insurance premiums, and 401(k) retirement account matching percentages.
  • Effective Dates of Coverage: New hires need to understand when their employee benefits kick in, whether that’s immediately upon hiring, after a 30-day waiting period, or after another waiting period.

Upload and Store Documents Related to Benefits

By uploading documents for employees into Gusto, the HR team doesn’t have to answer regular questions about the employee benefits plan.

The HR team also can upload documents directly to an employee’s dashboard that require review and signing. These can include a document for setting up a 401(k) account or for signing up for a health plan, for example.

To upload a document to the employee, start in the People section of Gusto. Click on the employee’s name.

On the employee page, click on Documents. In the upload section, follow the prompts to save the document to the employee’s dashboard. Once the employee completes the document, a notification will appear in the employer dashboard.

Step 2: Set up a Health Plan


One of the most basic benefits employees will expect is a health insurance plan. With Gusto, companies can find a health insurance package that fits the business’ finances and the employees’ needs.

Start a New Health Insurance Plan

When using Gusto, selecting a new health plan is an easy process.

Gusto has put together a collection of several potential health insurance plans that it offers to companies that subscribe to Gusto. (Subscribers can bring their own health insurance plan too, which we’ll discuss next.) Gusto’s available plans will work for companies of significantly varying sizes.

After signing up for a health insurance plan through Gusto, the HR software handles the payroll deduction for the employees. It also can deduct for vision, life, and dental insurance, when the company offers those benefits.

The deductions occur automatically in Gusto, and the HR department can synchronize those deductions with payroll runs. Gusto also handles compliance support for the health plan.

Migrate an Existing Health Plan

For companies that already offer health coverage and that want to start using Gusto, they can move the existing health insurance plan to manage it in Gusto.

At the time the company signs up for Gusto, HR personnel may enter the information about the current health insurance plan. Gusto will handle the process of making the employee payroll deductions and matching them up to payroll run times.

Step 3: Set up a 401(k) Plan

Another popular employee benefits option is a 401(k) retirement plan. It allows employees to contribute part of their paychecks before taxes, building money for retirement. Employers provide matching funds.

Multiple types of investments for 401(k) accounts are available, allowing the employee to match the investment to the appetite for risk.

Start a New 401(k) Plan

Gusto offers 401(k) plans through its partner, Guideline. In this partnership, a company subscribing to Gusto can start a 401(k) plan to offer its employees. Guideline has plans that can fit almost any size of business and the needs of the employees.

Administrators can start the process inside Gusto by clicking the Benefits tab. In the 401(k) section, click on the Offer New Benefits link. Then click Next. Add the desired information before clicking the Get Started button.

Gusto will send the administrator to the Guideline website. The administrator will be able to research and pick from several different options in retirement account plans.

Migrate an Existing 401(k) Plan

For companies that already offer their employees 401(k) retirement savings plans, they can track the plan in Gusto without signing up for a Guideline plan.

Within Gusto, look for the 401(k) section on the Benefits page and click Add. Follow the prompts until the Manage 401(k) with Gusto link appears on the page. Click on it.

Gusto will ask for information about the current plan the company has. Enter the requested information as prompted, including information to have Gusto begin managing automatic payroll deductions.

Step 4: Set up the Employee Dashboard


One advantage of using HR software like Gusto is that employees can handle some of the aspects of managing their employee benefits on their own. Every request doesn’t have to go through the HR department, which saves time.

The HR administrator can determine what types of information appear on the employee dashboard. The administrator controls what changes the employee can make through the dashboard too.

Some of the items the employee may be able to see and control in the dashboard include:

  • Health Plan Details: Employees can see information on the health plan deductible, the out-of-pocket maximum cost, any coinsurance due, any copayment due, costs for in-network doctors, costs for out-of-network doctors, and prescription drug costs.
  • Documents: When the employer uploads a document for the employee to sign, it’s accessible through the employee dashboard. The employee can submit it back to the employer through the dashboard too.
  • 401(k) Account Details: Employees can click on the Benefits tab to view information about an existing 401(k) account, including the account balance.
  • 401(k) Contribution: If the company manages its 401(k) account through Gusto and Guideline, employees can make changes to their payroll percentage contributions for the 401(k). They also can adjust the types of investments they’re making.
  • Paid Time off: For employees who have paid time off (PTO) benefits or sick leave benefits, they can manage these benefits in the dashboard. They can request a partial or full day off, and they can select multiple days. After submitting the request, the administrator will need to approve or deny the PTO in Gusto.

An Alternative Voice UI To Voice Assistants

For most people, the first thing that comes to mind when thinking of voice user interfaces are voice assistants, such as Siri, Amazon Alexa or Google Assistant. In fact, assistants are the only context where most people have ever used voice to interact with a computer system.

While voice assistants have brought voice user interfaces to the mainstream, the assistant paradigm is not the only, nor even the best way to use, design, and create voice user interfaces.

In this article, I’ll go through the issues voice assistants suffer from and present a new approach for voice user interfaces that I call direct voice interactions.

Voice Assistants Are Voice-Based Chatbots

A voice assistant is a piece of software that uses natural language instead of icons and menus as its user interface. Assistants typically answer questions and often proactively try to help the user.

Instead of straightforward transactions and commands, assistants mimic a human conversation and use natural language bi-directionally as the interaction modality, meaning it both takes input from the user and answers to the user by using natural language.

The first assistants were dialogue-based question-answering systems. One early example is Microsoft’s Clippy that infamously tried to aid users of Microsoft Office by giving them instructions based on what it thought the user was trying to accomplish. Nowadays, a typical use case for the assistant paradigm are chatbots, often used for customer support in a chat discussion.

Voice assistants, on the other hand, are chatbots that use voice instead of typing and text. The user input is not selections or text but speech and the response from the system is spoken out loud, too. These assistants can be general assistants such as Google Assistant or Alexa that can answer a multitude of questions in a reasonable way or custom assistants that are built for a special purpose such as fast-food ordering.

Although often the user’s input is just a word or two and can be presented as selections instead of actual text, as the technology evolves, the conversations will be more open-ended and complex. The first defining feature of chatbots and assistants is the use of natural language and conversational style instead of icons, menus, and transactional style that defines a typical mobile app or website user experience.

Recommended reading: Building A Simple AI Chatbot With Web Speech API And Node.js

The second defining characteristic that derives from the natural language responses is the illusion of a persona. The tone, quality, and language that the system uses define both the assistant experience, the illusion of empathy and susceptibility to service, and its persona. The idea of a good assistant experience is like being engaged with a real person.

Since voice is the most natural way for us to communicate, this might sound awesome, but there are two major problems with using natural language responses. One of these problems, related to how well computers can imitate humans, might be fixed in the future with the development of conversational AI technologies, but the problem of how human brains handle information is a human problem, not fixable in the foreseeable future. Let’s look into these problems next.

Two Problems With Natural Language Responses

Voice user interfaces are of course user interfaces that use voice as a modality. But voice modality can be used for both directions: for inputting information from the user and outputting information from the system back to the user. For example, some elevators use speech synthesis for confirming the user selection after the user presses a button. We’ll later discuss voice user interfaces that only use voice for inputting information and use traditional graphical user interfaces for showing the information back to the user.

Voice assistants, on the other hand, use voice for both input and output. This approach has two main problems:

Problem #1: Imitation Of A Human Fails

As humans, we have an innate inclination to attribute human-like features to non-human objects. We see the features of a man in a cloud drifting by or look at a sandwich and it seems like it’s grinning at us. This is called anthropomorphism.

This phenomenon applies to assistants too, and it is triggered by their natural language responses. While a graphical user interface can be built somewhat neutral, there’s no way a human could not start thinking about whether the voice of someone belongs to a young or an old person or whether they are male or a female. Because of this, the user almost starts to think that the assistant is indeed a human.

However, we humans are very good at detecting fakes. Strangely enough, the closer something comes to resembling a human, the more the small deviations start to disturb us. There is a feeling of creepiness towards something that tries to be human-like but does not quite measure up to it. In robotics and computer animations this is referred to as the “uncanny valley”.

The better and more human-like we try to make the assistant, the creepier and disappointing the user experience can be when something goes wrong. Everyone who has tried assistants has probably stumbled upon the problem of responding with something that feels idiotic or even rude.

The uncanny valley of voice assistants poses a problem of quality in assistant user experience that is hard to overcome. In fact, the Turing test (named after the famous mathematician Alan Turing) is passed when a human evaluator exhibiting a conversation between two agents cannot distinguish between which of them is a machine and which is a human. So far, it has never been passed.

This means that the assistant paradigm sets a promise of a human-like service experience that can never be fulfilled and the user is bound to get disappointed. The successful experiences only build up the eventual disappointment, as the user begins to trust their human-like assistant.

Problem 2: Sequential And Slow Interactions

The second problem of voice assistants is that the turn-based nature of natural language responses causes delay to the interaction. This is due to how our brains process information.

There are two types of data processing systems in our brains:

  • A linguistic system that processes speech;
  • A visuospatial system that specializes in processing visual and spatial information.

These two systems can operate in parallel, but both systems process only one thing at a time. This is why you can speak and drive a car at the same time, but you can’t text and drive because both of those activities would happen in the visuospatial system.

Similarly, when you are talking to the voice assistant, the assistant needs to stay quiet and vice versa. This creates a turn-based conversation, where the other part is always fully passive.

However, consider a difficult topic you want to discuss with your friend. You’d probably discuss face-to-face rather than over the phone, right? That is because in a face-to-face conversation we use non-verbal communication to give realtime visual feedback to our conversation partner. This creates a bi-directional information exchange loop and enables both parties to be actively involved in the conversation simultaneously.

Assistants don’t give realtime visual feedback. They rely on a technology called end-pointing to decide when the user has stopped talking and replies only after that. And when they do reply, they don’t take any input from the user at the same time. The experience is fully unidirectional and turn-based.

In a bi-directional and realtime face-to-face conversation, both parties can react immediately to both visual and linguistic signals. This utilizes the different information processing systems of the human brain and the conversation becomes smoother and more efficient.

Voice assistants are stuck in unidirectional mode because they are using natural language both as the input and output channels. While voice is up to four times faster than typing for input, it’s significantly slower to digest than reading. Because information needs to be processed sequentially, this approach only works well for simple commands such as “turn off the lights” that don’t require much output from the assistant.

Earlier, I promised to discuss voice user interfaces that employ voice only for inputting data from the user. This kind of voice user interfaces benefit from the best parts of voice user interfaces — naturalness, speed and ease-of-use — but don’t suffer from the bad parts — uncanny valley and sequential interactions

Let’s consider this alternative.

A Better Alternative To The Voice Assistant

The solution to overcome these problems in voice assistants is letting go of natural language responses, and replacing them with realtime visual feedback. Switching feedback to visual will enable the user to give and get feedback simultaneously. This will enable the application to react without interrupting the user and enabling a bidirectional information flow. Because the information flow is bidirectional, its throughput is bigger.

Currently, the top use cases for voice assistants are setting alarms, playing music, checking the weather, and asking simple questions. All of these are low-stakes tasks that don’t frustrate the user too much when failing.

As David Pierce from the Wall Street Journal once wrote:

“I can’t imagine booking a flight or managing my budget through a voice assistant, or tracking my diet by shouting ingredients at my speaker.”

— David Pierce from Wall Street Journal

These are information-heavy tasks that need to go right.

However, eventually, the voice user interface will fail. The key is to cover this as fast as possible. A lot of errors happen when typing on a keyboard or even in a face-to-face conversation. However, this is not at all frustrating as the user can recover simply by clicking the backspace and trying again or asking for clarification.

This fast recovery from errors enables the user to be more efficient and doesn’t force them into a weird conversation with an assistant.

“Isn’t this semantics?”, you might ask. If you are going to talk to the computer does it really matter if you are talking directly to the computer or through a virtual persona? In both cases, you are just talking to a computer!

Yes, the difference is subtle, but critical. When clicking a button or menu item in a GUI (Graphical User Interface) it is blatantly obvious that we are operating a machine. There is no illusion of a person. By replacing that clicking with a voice command, we are improving the human-computer interaction. With the assistant paradigm, on the other hand, we are creating a deteriorated version of the human-to-human interaction and hence, journeying into the uncanny valley.

Blending voice functionalities into the graphical user interface also offers the potential to harness the power of different modalities. While the user can use voice to operate the application, they have the ability to use the traditional graphical interface, too. This enables the user to switch between touch and voice seamlessly and choose the best option based on their context and task.

For example, voice is a very efficient method for inputting rich information. Selecting between a couple of valid alternatives, touch or click is probably better. The user can then replace typing and browsing by saying something like, “Show me flights from London to New York departing tomorrow,” and select the best option from the list by using touch.

Contrary to the traditional turn-based voice assistant systems that wait for the user to stop talking before processing the user request, systems using streaming spoken language understanding actively try to comprehend the user intent from the very moment the user starts to talk. As soon as the user says something actionable, the UI instantly reacts to it.

The instant response immediately validates that the system is understanding the user and encourages the user to go on. It’s analogous to a nod or a short “a-ha” in human-to-human communication. This results in longer and more complex utterances supported. Respectively, if the system does not understand the user or the user misspeaks, instant feedback enables fast recovery. The user can immediately correct and continue, or even verbally correct themself: “I want this, no I meant, I want that.” You can try this kind of application yourself in our voice search demo.

As you can see in the demo, the realtime visual feedback enables the user to correct themselves naturally and encourages them to continue with the voice experience. As they are not confused by a virtual persona, they can relate to possible errors in a similar way to typos — not as personal insults. The experience is faster and more natural because the information fed to the user is not limited by the typical rate of speech of about 150 words per minute.

Recommended reading: Designing Voice Experiences by Lyndon Cerejo

Conclusions

While voice assistants have been by far the most common use for voice user interfaces so far, the use of natural language responses makes them inefficient and unnatural. Voice is a great modality for inputting information, but listening to a machine talking is not very inspiring. This is the big issue of voice assistants.

The future of voice should therefore not be in conversations with a computer but in replacing tedious user tasks with the most natural way of communicating: speech. Direct voice interactions can be used to improve form filling experience in web or mobile applications, to create better search experiences, and to enable a more efficient way to control or navigate in an application.

Designers and app developers are constantly looking for ways to reduce friction in their apps or websites. Enhancing the current graphical user interface with a voice modality would enable multiple times faster user interactions especially in certain situations such as when the end-user is on mobile and on the go and typing is hard. In fact, voice search can be up to five times faster than a traditional search filtering user interface, even when using a desktop computer.

Next time, when you are thinking about how you can make a certain user task in your application easier to use, more enjoyable to use, or you are interested in increasing conversions, consider whether that user task can be described accurately in natural language. If yes, complement your user interface with a voice modality but don’t force your users to conversate with a computer.

Resources

can do you write c++ please

Generate a graph by forming an adjacency matrix with random numbers. The
graph will have 10 nodes. The connections will be generated randomly with
the following rules.
Each pair may have a connection with 60% probability. It means that
the connection weight for a node pair will be 0 with 40% probability.
If a pair has a connection, the connection weight will be drawn from a
uniform distribution in the range 1 to 10. Connection weights will be
positive integer values.
The graph is directed. Some connections may be one way and some
connections can be bidirectional.
Each node will have a letter as label, such as 'A', 'B', 'C'
After creating the graph, implement the following functions:
A function to generate adjacency list from the generated graph
A function to check if the graph is connected
If it is not connected, a function to return number of clusters (disjoint
subgraphs) with number of nodes in each cluster
A function to return breadth-first listing of each cluster. (It will return
label list in the order of breadth-first)
A function to return depth-first listing of each cluster
A function to compute minimum-spanning tree for each cluster
A function to return list of shortest path from a user given node name to
all nodes in a the cluster that node is located.

Java JMS Oversimplified

Java Messaging Service

JMS or Java Messaging service is a solution for asynchronous communication using messages (objects). Initially, it was part of JSR (specification used in Java EE).

Simple Problem as Example to Explain: User Creation Service

Let's assume we have any service that can process only 100 requests per second. Any higher load will freeze service or put it down.

Client-Side Routing In Next.js

Hyperlinks have been one of the jewels of the Web since its inception . According to MDN, hyperlinks are what makes the Web, a web. While used for purposes such as linking between documents, its primary use is to reference different web pages identifiable by a unique web address or a URL.

Routing is an important aspect of each web application as much as hyperlinks are to the Web. It is a mechanism through which requests are routed to the code that handles them. In relation to routing, Next.js pages are referenced and identifiable by a unique URL path. If the Web consists of navigational web pages interconnected by hyperlinks, then each Next.js app consists of route-able pages (route handlers or routes) interconnected by a router.

Next.js has built-in support for routing that can be unwieldy to unpack, especially when considering rendering and data fetching. As a prerequisite to understanding client-side routing in Next.js, it is necessary to have an overview of concepts like routing, rendering, and data fetching in Next.js.

This article will be beneficial to React developers who are familiar with Next.js and want to learn how it handles routing. You need to have a working knowledge of React and Next.js to get the most out of the article, which is solely about client-side routing and related concepts in Next.js.

Routing And Rendering

Routing and Rendering are complementary to each other and will play a huge part through the course of this article. I like how Gaurav explains them:

Routing is the process through which the user is navigated to different pages on a website.

Rendering is the process of putting those pages on the UI. Every time you request a route to a particular page, you are also rendering that page, but not every render is an outcome of a route.

Take five minutes to think about that.

What you need to understand about rendering in Next.js is that each page is pre-rendered in advance alongside the minimal JavaScript code necessary for it to become fully interactive through a process known as hydration. How Next.js does this is highly dependent on the form of pre-rendering: Static Generation or Server-side rendering, which are both highly coupled to the data fetching technique used, and separated by when the HTML for a page is generated.

Depending on your data fetching requirements, you might find yourself using built-in data fetching functions like getStaticProps, getStaticPaths, or, getServerSideProps, client-side data fetching tools like SWR, react-query, or traditional data fetching approaches like fetch-on-render, fetch-then-render, render-as-you-fetch (with Suspense).

Pre-rendering (before rendering — to the UI) is complementary to Routing, and highly coupled with data fetching — a whole topic of its own in Next.js. So while these concepts are either complementary or closely related, this article will be solely focused on mere navigation between pages (routing), with references to related concepts where necessary.

With that out of the way, let’s begin with the fundamental gist: Next.js has a file-system-based router built on the concept of pages.

Pages

Pages in Next.js are React Components that are automatically available as routes. They are exported as default exports from the pages directory with supported file extensions like .js, .jsx, .ts, or .tsx.

A typical Next.js app will have a folder structure with top-level directories like pages, public, and styles.

next-app
├── node_modules
├── pages
│   ├── index.js // path: base-url (/)
│   ├── books.jsx // path: /books
│   └── book.ts // path: /book
├── public
├── styles
├── .gitignore
├── package.json
└── README.md

Each page is a React component:

// pages/books.js — `base-url/book`
export default function Book() {
  return Books
}

Note: Keep in mind that pages can also be referred to as “route handlers”.

Custom Pages

These are special pages that reside in the pages directory but do not participate in routing. They are prefixed with the underscore symbol, as in, _app.js, and _document.js.

  • _app.js
    This is a custom component that resides in the pages folder. Next.js uses this component to initialize pages.
  • _document.js
    Like _app.js, _document.js is a custom component that Next.js uses to augment your applications <html> and <body> tags. This is necessary because Next.js pages skip the definition of the surrounding document’s markup.
next-app
├── node_modules
├── pages
│   ├── _app.js // ⚠️ Custom page (unavailable as a route)
│   ├── _document.jsx // ⚠️ Custom page (unavailable as a route)
│   └── index.ts // path: base-url (/)
├── public
├── styles
├── .gitignore
├── package.json
└── README.md

Linking Between Pages

Next.js exposes a Link component from the next/link API that can be used to perform client-side route transitions between pages.

// Import the <Link/> component
import Link from "next/link";

// This could be a page component
export default function TopNav() {
  return (
    <nav>
      <Link href="/">Home</Link>
      <Link href="/">Publications</Link>
      <Link href="/">About</Link>
    </nav>
  )
}

// This could be a non-page component
export default function Publications() {
  return (
    <section>
      <TopNav/>
      {/* ... */}
    </section>
  )
}

The Link component can be used inside any component, page or not. When used in its most basic form as in the example above, the Link component translates to a hyperlink with an href attribute. (More on Link in the next/link section below.)

Routing

Next.js file-based routing system can be used to define the most common route patterns. To accommodate for these patterns, each route is separated based on its definition.

Index Routes

By default, in your Next.js app, the initial/default route is pages/index.js which automatically serves as the starting point of your application as /. With a base URL of localhost:3000, this index route can be accessed at the base URL level of the application in the browser.

Index routes automatically act as the default route for each directory and can eliminate naming redundancies. The directory structure below exposes two route paths: / and /home.

next-app
└── pages
    ├── index.js // path: base-url (/)
    └── home.js // path: /home

The elimination is more apparent with nested routes.

Nested Routes

A route like pages/book is one level deep. To go deeper is to create nested routes, which requires a nested folder structure. With a base-url of https://www.smashingmagazine.com, you can access the route https://www.smashingmagazine.com/printed-books/printed-books by creating a folder structure similar to the one below:

next-app
└── pages
    ├── index.js // top index route
    └── printed-books // nested route
        └── printed-books.js // path: /printed-books/printed-books

Or eliminate path redundancy with index routes and access the route for printed books at https://www.smashingmagazine.com/printed-books.

next-app
└── pages
    ├── index.js // top index route
    └── printed-books // nested route
        └── index.js // path: /printed-books

Dynamic routes also play an important role in eliminating redundancies.

Dynamic Routes

From the previous example we use the index route to access all printed books. To access individual books requires either creating different routes for each book like:

// ⚠️ Don't do this.
next-app
└── pages
    ├── index.js // top index route
    └── printed-books // nested route
        ├── index.js // path: /printed-books
        ├── typesript-in-50-lessons.js // path: /printed-books/typesript-in-50-lessons
        ├── checklist-cards.js // path: /printed-books/checklist-cards
        ├── ethical-design-handbook.js // path: /printed-books/ethical-design-handbook
        ├── inclusive-components.js // path: /printed-books/inclusive-components
        └── click.js // path: /printed-books/click

which is highly redundant, unscalable, and can be remedied with dynamic routes like:

// ✅ Do this instead.
next-app
└── pages
    ├── index.js // top index route
    └── printed-books
        ├── index.js // path: /printed-books
        └── [book-id].js // path: /printed-books/:book-id

The bracket syntax — [book-id] — is the dynamic segment, and is not limited to files alone. It can also be used with folders like the example below, making the author available at the route /printed-books/:book-id/author.

next-app
└── pages
    ├── index.js // top index route
    └── printed-books
        ├── index.js // path: /printed-books
        └── [book-id]
            └── author.js // path: /printed-books/:book-id/author

The dynamic segment(s) of a route is exposed as a query parameter that can be accessed in any of the connecting component involved in the route with query object of the useRouter() hook — (More on this in the next/router API section).

// printed-books/:book-id
import { useRouter } from 'next/router';

export default function Book() {
  const { query } = useRouter();

  return (
    <div>
      <h1>
        book-id <em>{query['book-id']}</em>
      </h1>
    </div>
  );
}
// /printed-books/:book-id/author
import { useRouter } from 'next/router';

export default function Author() {
  const { query } = useRouter();

  return (
    <div>
      <h1>
        Fetch author with book-id <em>{query['book-id']}</em>
      </h1>
    </div>
  );
}

Extending Dynamic Route Segments With Catch All Routes

You’ve seen the dynamic route segment bracket syntax as in the previous example with [book-id].js. The beauty of this syntax is that it takes things even further with Catch-All Routes. You can infer what this does from the name: it catches all routes.

When we looked at the dynamic example, we learned how it helps eliminate file creation redundancy for a single route to access multiple books with their ID. But there’s something else we could have done.

Specifically, we had the path /printed-books/:book-id, with a directory structure:

next-app
└── pages
    ├── index.js
    └── printed-books
        ├── index.js
        └── [book-id].js

If we updated the path to have more segments like categories, we might end up with something like: /printed-books/design/:book-id, /printed-books/engineering/:book-id, or better still /printed-books/:category/:book-id.

Let’s add the release year: /printed-books/:category/:release-year/:book-id. Can you see a pattern? The directory structure becomes:

next-app
└── pages
    ├── index.js
    └── printed-books
        └── [category]
            └── [release-year]
                └── [book-id].js

We substituted the use of named files for dynamic routes, but somehow still ended up with another form of redundancy. Well, there’s a fix: Catch All Routes that eliminates the need for deeply nested routes:

next-app
└── pages
    ├── index.js
    └── printed-books
        └── [...slug].js

It uses the same bracket syntax except that it is prefixed with three dots. Think of the dots like the JavaScript spread syntax. You might be wondering: If I use the catch-all routes, how do I access the category ([category]), and release year ([release-year]). Two ways:

  1. In the case of the printed-books example, the end goal is the book, and each book info will have its metadata attached with it, or
  2. The “slug” segments are returned as an array of query parameter(s).
import { useRouter } from 'next/router';

export default function Book() {
  const { query } = useRouter();
  // There's a brief moment where slug is undefined
  // so we use the Optional Chaining (?.) and Nullish coalescing operator (??)
  // to check if slug is undefined, then fall back to an empty array
  const [category, releaseYear, bookId] = query?.slug ?? [];

  return (
    <table>
      <tbody>
        <tr>
          <th>Book Id</th>
          <td>{bookId}</td>
        </tr>
        <tr>
          <th>Category</th>
          <td>{category}</td>
        </tr>
        <tr>
          <th>Release Year</th>
          <td>{releaseYear}</td>
        </tr>
      </tbody>
    </table>
  );
}

Here’s more example for the route /printed-books/[…slug]:

Path Query parameter
/printed-books/click.js { “slug”: [“click”] }
/printed-books/2020/click.js { “slug”: [“2020”, “click”] }
/printed-books/design/2020/click.js { “slug”: [“design”, “2020”, “click”] }

As it is with the catch-all route, the route /printed-books will throw a 404 error unless you provide a fallback index route.

next-app
└── pages
    ├── index.js
    └── printed-books
        ├── index.js // path: /printed-books
        └── [...slug].js

This is because the catch-all route is “strict”. It either matches a slug, or it throws an error. If you’d like to avoid creating index routes alongside catch-all routes, you can use the optional catch-all routes instead.

Extending Dynamic Route Segments With Optional Catch-All Routes

The syntax is the same as catch-all-routes, but with double square brackets instead.

next-app
└── pages
    ├── index.js
    └── printed-books
        └── [[...slug]].js

In this case, the catch-all route (slug) is optional and if not available, fallbacks to the path /printed-books, rendered with [[…slug]].js route handler, without any query params.

Use catch-all alongside index routes, or optional catch-all routes alone. Avoid using catch-all and optional catch-all routes alongside.

Routes Precedence

The capability to be able to define the most common routing patterns can be a “black swan”. The possibility of routes clashing is a looming threat, most especially when you start getting dynamic routes worked up.

When it makes sense to do so, Next.js lets you know about route clashes in the form of errors. When it doesn’t, it applies precedence to routes according to their specificity.

For example, it is an error to have more than one dynamic route on the same level.

// ❌ This is an error
// Failed to reload dynamic routes: Error: You cannot use different slug names for the // same dynamic path ('book-id' !== 'id').
next-app
└── pages
    ├── index.js
    └── printed-books
        ├── [book-id].js
        └── [id].js

If you look closely at the routes defined below, you’d notice the potential for clashes.

// Directory structure flattened for simplicity
next-app
└── pages
    ├── index.js // index route (also a predefined route)
    └── printed-books
        ├── index.js
        ├── tags.js // predefined route
        ├── [book-id].js // handles dynamic route
        └── [...slug].js // handles catch all route

For example, try answering this: what route handles the path /printed-books/inclusive-components?

  • /printed-books/[book-id].js, or
  • /printed-books/[…slug].js.

The answer lies in the “specificity” of the route handlers. Predefined routes come first, followed by dynamic routes, then catch-all routes. You can think of the route request/handling model as a pseudo-code with the following steps:

  1. Is there is a predefined route handler that can handle the route?
    • true — handle the route request.
    • false — go to 2.
  2. Is there a dynamic route handler that can handle the route?
    • true — handle the route request.
    • false — go to 3.
  3. Is there a catch-all route handler that can handle the route?
    • true — handle the route request.
    • false — throw a 404 page not found.

Therefore, /printed-books/[book-id].js wins.

Here are more examples:

Route Route handler Type of route
/printed-books /printed-books Index route
/printed-books/tags /printed-books/tags.js Predefined route
/printed-books/inclusive-components /printed-books/[book-id].js Dynamic route
/printed-books/design/inclusive-components /printed-books/[...slug].js Catch-all route

The next/link API

The next/link API exposes the Link component as a declarative way to perform client-side route transitions.

import Link from 'next/link'

function TopNav() {
  return (
    <nav>
      <Link href="/">Smashing Magazine</Link>
      <Link href="/articles">Articles</Link>
      <Link href="/guides">Guides</Link>
      <Link href="/printed-books">Books</Link>
    </nav>
  )
}

The Link component will resolve to a regular HTML hyperlink. That is, <Link href="/">Smashing Magazine</Link> will resolve to <a href="/">Smashing Magazine</a>.

The href prop is the only required prop to the Link component. See the docs for a complete list of props available on the Link component.

There are other mechanisms of the Link component to be aware of.

Routes With Dynamic Segments

Prior to Next.js 9.5.3, Linking to dynamic routes meant that you had to provide both the href and as prop to Link as in:

import Link from 'next/link';

const printedBooks = [
  { name: 'Ethical Design', id: 'ethical-design' },
  { name: 'Design Systems', id: 'design-systems' },
];

export default function PrintedBooks() {
  return printedBooks.map((printedBook) => (
    <Link
      href="/printed-books/[printed-book-id]"
      as={`/printed-books/${printedBook.id}`}
    >
      {printedBook.name}
    </Link>
  ));
}

Although this allowed Next.js to interpolate the href for the dynamic parameters, it was tedious, error-prone, and somewhat imperative, and has now been fixed for the majority of use-cases with the release of Next.js 10.

This fix is also backward compatible. If you have been using both as and href, nothing breaks. To adopt the new syntax, discard the href prop and its value, and rename the as prop to href as in the example below:

import Link from 'next/link';

const printedBooks = [
  { name: 'Ethical Design', id: 'ethical-design' },
  { name: 'Design Systems', id: 'design-systems' },
];

export default function PrintedBooks() {
  return printedBooks.map((printedBook) => (
    <Link href={/printed-books/${printedBook.id}}>{printedBook.name}</Link>
  ));
}

See Automatic resolving of href.

Use-cases For The passHref Prop

Take a close look at the snippet below:

import Link from 'next/link';

const printedBooks = [
  { name: 'Ethical Design', id: 'ethical-design' },
  { name: 'Design Systems', id: 'design-systems' },
];

// Say this has some sort of base styling attached
function CustomLink({ href, name }) {
  return <a href={href}>{name}</a>;
}

export default function PrintedBooks() {
  return printedBooks.map((printedBook) => (
    <Link href={/printed-books/${printedBook.id}} passHref>
      <CustomLink name={printedBook.name} />
    </Link>
  ));
}

The passHref props force the Link component to pass the href prop down to the CustomLink child component. This is compulsory if the Link component wraps over a component that returns a hyperlink <a> tag. Your use-case might be because you are using a library like styled-components, or if you need to pass multiple children to the Link component, as it only expects a single child.

See the docs to learn more.

URL Objects

The href prop of the Link component can also be a URL object with properties like query which is automatically formatted into a URL string.

With the printedBooks object, the example below will link to:

  1. /printed-books/ethical-design?name=Ethical+Design and
  2. /printed-books/design-systems?name=Design+Systems.
import Link from 'next/link';

const printedBooks = [
  { name: 'Ethical Design', id: 'ethical-design' },
  { name: 'Design Systems', id: 'design-systems' },
];

export default function PrintedBooks() {
  return printedBooks.map((printedBook) => (
    <Link
      href={{
        pathname: `/printed-books/${printedBook.id}`,
        query: { name: `${printedBook.name}` },
      }}
    >
      {printedBook.name}
    </Link>
  ));
}

If you include a dynamic segment in the pathname, then you must also include it as a property in the query object to make sure the query is interpolated in the pathname:

import Link from 'next/link';

const printedBooks = [
  { name: 'Ethical Design', id: 'ethical-design' },
  { name: 'Design Systems', id: 'design-systems' },
];

// In this case the dynamic segment `[book-id]` in pathname
// maps directly to the query param `book-id`
export default function PrintedBooks() {
  return printedBooks.map((printedBook) => (
    <Link
      href={{
        pathname: `/printed-books/[book-id]`,
        query: { 'book-id': `${printedBook.id}` },
      }}
    >
      {printedBook.name}
    </Link>
  ));
}

The example above have paths:

  1. /printed-books/ethical-design, and
  2. /printed-books/design-systems.

If you inspect the href attribute in VSCode, you’d find the type LinkProps, with the href property a Url type, which is either a string or UrlObject as mentioned previously.

Inspecting the UrlObject further leads to the interface with the properties:

You can learn more about these properties in the Node.js URL module documentation.

One use case of the hash is to link to specific sections in a page.

import Link from 'next/link';

const printedBooks = [{ name: 'Ethical Design', id: 'ethical-design' }];

export default function PrintedBooks() {
  return printedBooks.map((printedBook) => (
    <Link
      href={{
        pathname: /printed-books/${printedBook.id},
        hash: 'faq',
      }}
    >
      {printedBook.name}
    </Link>
  ));
}

The hyperlink will resolve to /printed-books/ethical-design#faq.

Learn more in the docs.

The next/router API

If the next/link is declarative, then the next/router is imperative. It exposes a useRouter hook that allows access to the router object inside any function component. You can use this hook to manually perform routing, most especially in certain scenarios where the next/link is not enough, or where you need to “hook” into the routing.

import { useRouter } from 'next/router';

export default function Home() {
  const router = useRouter();

  function handleClick(e) {
    e.preventDefault();
    router.push(href);
  }

  return (
    <button type="button" onClick={handleClick}>Click me</button>
  )
}

useRouter is a React hook and cannot be used with classes. Need the router object in class components? Use withRouter.

import { withRouter } from 'next/router';

function Home({router}) {
  function handleClick(e) {
    e.preventDefault();
    router.push(href);
  }

  return (
    <button type="button" onClick={handleClick}>Click me</button>
  )
}

export default withRouter(Home);

The router Object

Both the useRouter hook and withRouter higher-order component, return a router object with properties like pathname, query, asPath, and basePath that gives you information about the URL state of the current page, locale, locales, and defaultLocale that gives information about the active, supported, or current default locale.

The router object also has methods like push for navigating to a new URL by adding a new URL entry into the history stack, replace, similar to push but replaces the current URL instead of adding a new URL entry into the history stack.

Learn more about the router object.

Custom Route Configuration With next.config.js

This is a regular Node.js module that can be used to configure certain Next.js behavior.

module.exports = {
  // configuration options
}

Remember to restart your server anytime you update next.config.js. Learn more.

Base Path

It was mentioned that the initial/default route in Next.js is pages/index.js with path /. This is configurable and you can make your default route a sub-path of the domain.

module.exports = {
  // old default path: /
  // new default path: /dashboard
  basePath: '/dashboard',
};

These changes will automatically take effect in your application with all / paths routed to /dashboard.

This feature can only be used with Next.js 9.5 and above. Learn more.

Trailing Slash

By default, a trailing slash will not be available at the end of each URL. However, you can switch that with:

module.exports = {
  trailingSlash: true
};
# trailingSlash: false
/printed-books/ethical-design#faq
# trailingSlash: true
/printed-books/ethical-design/#faq

Both the base path and trailing slash features can only be used with Next.js 9.5 and above.

Conclusion

Routing is one of the most important parts of your Next.js application, and it reflects in the file-system-based router built on the concept of pages. Pages can be used to define the most common route patterns. The concepts of routing and rendering are closely related. Take the lessons of this article with you as you build your own Next.js app or work on a Next.js codebase. And check the resources below to learn more.

Related Resources

IoT Security: What Your Business Needs to Know

The internet of things (IoT) remains a popular subset of the information technology (IT) realm. However, despite its advancements, IoT is still in its infancy. By 2027, the global IoT market is estimated to be worth over $1,463.19 billion USD

With massive leaps in IoT technology and a rapidly changing landscape, IoT security is a budding concern. Here's what you need to know about IoT security.

Using Machine Learning to Detect Dupes: Some Real-Life Examples

As companies collect more and more data about their customers, an increased amount of duplicate information starts appearing in the data as well, causing a lot of confusion among internal teams. Since it would be impossible to manually go through all of the data and delete the duplicates, companies have come up with machine learning solutions that perform such work for them. Today we would like to take a look at some interesting uses of machine learning to catch duplicates in all kinds of environments. Before we dive right in, let’s take a look at how machine learning systems work.

How Do Machine Learning Systems Identify Duplicates?

When a person looks at an image or two strings of data it would be fairly easy for them to determine whether or not the images or strings are duplicates. However, how would you train a machine to spot such duplicates? Perhaps a good starting point would be to identify all of the similarities, but then you would need to explain exactly what 'similar' means. Are there gradations to similarities? In order to overcome such challenges, researchers use string metrics to train machine learning models.

What I Learned by Relearning HTML

I’ve worked on websites for several years, both professionally and for side projects. One day, I reflected on the fact that all of my web development education had come from actually making websites. In most cases, I’d have a specific problem, Google how to solve it and learn something new in the process.

I wondered what I was missing by never learning HTML in a comprehensive way. Forget CSS and JavaScript. I’m just talking about raw HTML. It might seem silly to go back to such a basic aspect of web development after a decent amount of experience, but it’s easy to become overconfident with a skill just because you know enough to do a few useful things.