Sitename environment variable

Let’s say my site url is https://gurucore.netlify.com
I think Netlify provide a new metadata environment variable of NETLIFY_SITENAME=gurucore will be useful.

Why:
Making a mono repo, I can build an WhiteLabel site (or generate static site) for several customers. Each customer metadata and assets (APIKey, link, logo, images, …) is placed in his dedicated theme folder.
Base on sitename, I can choose which theme I will build on which site.

One github repo, many sites on netlify, just build the different pieces.

1 Like

Hi @lockevn, you can already set up your own custom environment variables:

More information here:

Sorry for late reply.

Hi Perry, definitely I can setup my own customer environment var. But for every site, I have to do the same task (declare the var SITENAME, and set it exactly to my sitename). Whenever I have to change my sitename (rarely), I have to change that envvar.
Imagine I have 10 customers. All of them share the same codebase (of my own static generated sites).

if Netlify do it from your side, we can depend on it as a trust source to know current Netlify site this code is. It is really similar to Netlify Git metadata BRANCH and HEAD.

Actually, I have to use BRANCH for this purpose, and create git branch for each white-label site I support.

Hi, @lockevn, I’ve filed a feature request asking for us to include this environment variable when deploys with builds occur for a site.

If/when this becomes possible, we will post here in this topic to let you know about it.

In the meantime, we do include a DEPLOY_URL environment variable. This includes the site subdomain/name. You could parse this environment variable to extract the subdomain of the site that way.

If there are other questions about this, please let us know.

1 Like

Hey @lockevn,
Not sure if this will still come in handy for you but wanted to let you know that we now have a variable called SITE_NAME available during build :tada: You can check it out in this section of our docs: Build environment variables | Netlify Docs

1 Like