Ads.txt

Description

The ads.txt file is a global initiative to authorize digital sellers on a specific domain. Frontity needs support for the creation and configuration of such a file, which is at the root of the domain:

https://mydomain.com/ads.txt

User Stories

As a Frontity developer
I want to be able to create an ads.txt file
so that I can run ads in my domain

Examples

The ads.txt file contains plain text, like:

smartadserver.com, 1234, DIRECT
appnexus.com, 1234, DIRECT
rubiconproject.com, 1234, DIRECT
aol.com, 1234, RESELLER

Possible solution

When using Frontity in Embedded mode, users could use any WordPress plugin for this, like https://wordpress.org/plugins/ads-txt/.

When using Frontity in Decoupled mode, we have several options:

When running Frontity with NodeJS

We can check if an ads.txt file is in the file-system, similar to what we do with the favicon.ico or the robots.txt file.

This has the problem that for a multisite project, all the sites will have to share the same file.

@JmcGraphics has already started a PR to make this happen: https://github.com/frontity/frontity/pull/509

When using Vercel (or other similar hostings)

For hostings like Vercel, we need to add the file to their configuration.

This is similar to what we did for the robots.txt file, which is added if it’s present: https://github.com/frontity/now-builder/pull/23/files

EDIT: @JmcGraphics has done a PR to add this to our Now/Vercel builder. It’s released now.

Using a Frontity package

Once we have Server Extensibility, we can solve this with a package. It could be something like @frontity/ads-txt and it could have two modes.

1. Use frontity.settings.js for the content

Users could set the ads.txt content in their frontity.settings.js file. This would also allow to have different configurations for the different sites.

export default {
  packages: [
    {
      name: "@frontity/ads.txt",
      state: {
        adsTxt: {
          content: `
            smartadserver.com, 1234, DIRECT
            appnexus.com, 1234, DIRECT
            rubiconproject.com, 1234, DIRECT
            aol.com, 1234, RESELLER
          `,
        },
      },
    },
  ],
};

2. Fetch an ads.txt from WordPress

export default {
  packages: [
    {
      name: "@frontity/ads.txt",
      state: {
        adsTxt: {
          origin: "https://wp.mydomain.com/ads.txt",
        },
      },
    },
  ],
};

Both solutions will work with hostings like Vercel as well.

@JmcGraphics has just done a PR to add this to the Now builder: https://github.com/frontity/now-builder/pull/24

I’ve merged it and published a new version of the builder. It should be working now.

2 Likes

Great contribution @JmcGraphics :slight_smile:

Hello,
my client needs and ads.txt like that, I’m on vercel…But I’m not sure to understand how to add it.
Could you explain it in a more extensive way?
Thanks in advance

Hey @alexaspalato, you can add it to the root folder and the Vercel builder should pick it up from there.

Thank you!

How do you use this? I’ve added an ads.txt to the root of my project and built it but it isn’t being picked up and the path to /ads.txt is seen as a wordpress one.

It hasn’t been implemented yet.

There is a PR, but it wasn’t finished.

If you want to create a new PR for it, I’ll gladly review and merge it :slightly_smiling_face: