Home
Support Forums

Subdomain Branch links to <mysite>.netlify.app not my domain

Hi, I am very much new here, just using netlify for a month. I was adding subdomain branches to my site. Deploying the build is successful but the main issue I’m having is that my blog subdomain has “subdomain–sitename.netlify.app” instead of “subdomain.domain.com”. Any help?

Are you using Netlify DNS that is have you used the Nameservers Netlify gave you to connect your domain or have you used CNAME/ALIAS and A records? From what I know, branch subdomains are automatically generated at your domain if you are using Netlify DNS.

I am using Netlify DNS

You can try manually creating a CNAME record with the name as subdomain and value as subdomain–sitename.netlify.app. However, I guess, SSL certificates are not automatically issued for subdomain on a custom domain. So, to get SSL working, you’d have to let Netlify know, through this or some other thread.

Thanks I’ll try that. Netlify actually uses Wildcard SSL Certificates, i.e. *.domain.com.

I said you’ll have to request SSL because I have seen many threads around asking for the same. So, I just assumed. If you manage to get it done with any request, that’s great. You can check this one for example: Certificate extension request

Ahh, I thought that they automatically issue Wildcard SSL Certs because I have it in my settings as such.

I have done what you said but its still the same. My site links are still in blog--sitename.domain.com, maybe in config? like in netlify.toml?

Sorry, but, that’s the end of my guess. It should have worked by now, but if it’s not, there’s something else that’s wrong. You’ll have to wait for better answers.

Well thanks anyways. :smiley:

Hi, @KleinReveche. I believe the root cause is that the hugo site build is adding the custom domain because your branch builds say to do this in the build command itself (by using the -b option to define a base URL).

This is what I see as the build command in the logs for the branch deploys:

4:05:16 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'hugo --gc --minify -b $DEPLOY_PRIME_URL' versus 'hugo' in the Netlify UI

This is causing the HTML to use this domain name (the branch deploys subdomain under netlify.app) for the URLs instead of using relative URLs. If you change your build command, this should resolve the issue.

If there are other questions or concerns, please let us know.

I tried to do it by:

[context.branch-deploy]
command = “hugo --gc --minify -b blog.example.com

But, I get https://blog.example.com/blog.example.com/ and https://blog.example.com/blog.example.com/posts/postname/blog.example.com.

What did I do wrong? Please let me know.

That’s probably because of how your Hugo theme or code is setup. {{ .Site.BaseURL }} is the parameter that renders the configured base URL for your website, so, check where and how it’s being used.

I was wondering about that, I was deploying another branch just an hour ago and it was actually fine. Maybe the source is the Theme? I’ll check the {{ .Site.BaseURL }} first.

I checked, {{ .Site.BaseURL }} does not appear in the theme.

Here is my Netlify.toml for reference: https://pastebin.com/NzeRtfjy

It’s getting difficult to reach to any conclusion without source code or final link or anything. This is just me making random guesses here.

Here: https://github.com/KleinReveche/kleinreveche.com/tree/blog.
Here is the site: https://blog.kleinreveche.com/
Also thank you for taking the time to help me. I appreciate it. :smiley:

The source code isn’t working for me. I downloaded your repo, ran the hugo server command and I got a lot of warnings saying no layout for exists:

hugo server
Start building sites … 
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for layout "archives" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.   
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.   
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.   
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.   
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.   
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:25 found no layout file for "HTML" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

                   | EN  
-------------------+-----
  Pages            | 17
  Paginator pages  |  0
  Non-page files   |  0
  Static files     | 25
  Processed images |  0
  Aliases          |  3
  Sitemaps         |  1
  Cleaned          |  0  

Built in 563 ms
Watching for changes in C:\Users\Hrishikesh\Desktop\kleinreveche.com-blog\{archetypes,assets,content,data,i18n,layouts,static}
Watching for config changes in C:\Users\Hrishikesh\Desktop\kleinreveche.com-blog\config.toml, C:\Users\Hrishikesh\Desktop\kleinreveche.com-blog\config\_default, C:\Users\Hrishikesh\Desktop\kleinreveche.com-blog\config\_default\menus
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
WARN 2020/11/02 16:56:46 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:46 found no layout file for "HTML" for layout "archives" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/11/02 16:56:46 found no layout file for "HTML" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

Is it working normally for you?

I use hugo server for testing. Its fine for me.

❯ hugo server -D
Start building sites …

               | EN  

-------------------±----
Pages | 47
Paginator pages | 0
Non-page files | 0
Static files | 74
Processed images | 0
Aliases | 21
Sitemaps | 1
Cleaned | 0

Built in 704 ms
Watching for changes in /home/klr2003/Projects/kleinreveche.com/blog/{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in /home/klr2003/Projects/kleinreveche.com/blog/config.toml, /home/klr2003/Projects/kleinreveche.com/blog/config/_default, /home/klr2003/Projects/kleinreveche.com/blog/config/_default/menus
Environment: “development”
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

The problem was on my end. When I downloaded your repo from GitHub, it didn’t include the contents of the ‘theme’ folder.

So, we might have some progress. I can see that in the theme, there are variables like {{ .Permalink }} that are used, and so, your relative links are being used as absolute ones. Can you try replacing it with {{ .RelPermalink }}? It will make your URLs relative, so, it should not matter what URL is configured in base URL. I can’t go through the entire code, so, I can’t list all (possible) problems at once. This is just a guess and might lead somewhere, so, once we can narrow it down to one thing, rest can get easier.