[Normal behavior] Internal links not working on Netlify deploy preview

I have an existing Hugo site on GitHub that is linked to Netlify.

I made a new post, and wanted to test what it would look like. It rendered fine in localhost after building with hugo and previewing with hugo server. I created a pull request from the dev branch in the repo which automates a deploy preview in Netlify. The post was missing. When I add the post the number of pages built goes from 34 to 35 and when I remove the post it goes back down to 34.

Will attempt to post screenshots below…

Netlify deploy preview log

11:19:19 PM: Build ready to start
11:19:20 PM: build-image version: 30f629161c0736b1a3ecd8b418e5eeffab5c0faf
11:19:20 PM: build-image tag: v3.3.14
11:19:20 PM: buildbot version: aa59e39d11a12285101dd70bcbb5879d0279bee6
11:19:21 PM: Fetching cached dependencies
11:19:21 PM: Starting to download cache of 132.0MB
11:19:22 PM: Finished downloading cache in 869.893473ms
11:19:22 PM: Starting to extract cache
11:19:26 PM: Finished extracting cache in 4.610970945s
11:19:26 PM: Finished fetching cache in 5.523150445s
11:19:26 PM: Starting to prepare the repo for build
11:19:27 PM: Preparing Git Reference pull/1/head
11:19:28 PM: Starting build script
11:19:28 PM: Installing dependencies
11:19:28 PM: Started restoring cached node version
11:19:32 PM: Finished restoring cached node version
11:19:32 PM: v10.20.1 is already installed.
11:19:33 PM: Now using node v10.20.1 (npm v6.14.4)
11:19:33 PM: Started restoring cached build plugins
11:19:33 PM: Finished restoring cached build plugins
11:19:33 PM: Attempting ruby version 2.6.2, read from environment
11:19:34 PM: Using ruby version 2.6.2
11:19:34 PM: Using PHP version 5.6
11:19:34 PM: 5.2 is already installed.
11:19:34 PM: Using Swift version 5.2
11:19:34 PM: Installing Hugo 0.69.0
11:19:34 PM: Hugo Static Site Generator v0.69.0-4205844B/extended linux/amd64 BuildDate: 2020-04-10T09:16:58Z
11:19:34 PM: Started restoring cached go cache
11:19:34 PM: Finished restoring cached go cache
11:19:34 PM: go version go1.12 linux/amd64
11:19:34 PM: go version go1.12 linux/amd64
11:19:34 PM: Installing missing commands
11:19:34 PM: Verify run directory
11:19:34 PM: Executing user command: hugo
11:19:35 PM: Building sites …
11:19:35 PM: WARN 2020/05/21 04:19:35 Page.RSSLink is deprecated and will be removed in a future release. Use the Output Format's link, e.g. something like:
11:19:35 PM:     {{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}
11:19:35 PM:                    | EN
11:19:35 PM: -------------------+-----
11:19:35 PM:  Pages            | 35
11:19:35 PM:   Paginator pages  |  0
11:19:35 PM:   Non-page files   |  0
11:19:35 PM:  Static files     | 15
11:19:35 PM:   Processed images |  0
11:19:35 PM:   Aliases          |  0
11:19:35 PM:  Sitemaps         |  1
11:19:35 PM:   Cleaned          |  0
11:19:35 PM: Total in 37 ms
11:19:35 PM: Skipping functions preparation step: no functions directory set
11:19:35 PM: Caching artifacts
11:19:35 PM: Started saving build plugins
11:19:35 PM: Finished saving build plugins
11:19:35 PM: Started saving pip cache
11:19:43 PM: Finished saving pip cache
11:19:43 PM: Started saving emacs cask dependencies
11:19:43 PM: Finished saving emacs cask dependencies
11:19:43 PM: Started saving maven dependencies
11:19:43 PM: Finished saving maven dependencies
11:19:43 PM: Started saving boot dependencies
11:19:43 PM: Finished saving boot dependencies
11:19:43 PM: Started saving go dependencies
11:19:43 PM: Finished saving go dependencies
11:19:43 PM: Build script success
11:19:43 PM: Starting to deploy site from 'public'
11:19:43 PM: Creating deploy tree 
11:19:43 PM: Creating deploy upload records
11:19:43 PM: 0 new files to upload
11:19:43 PM: 0 new functions to upload
11:19:43 PM: Starting post processing
11:19:44 PM: Post processing done
11:19:44 PM: Site is live
11:20:30 PM: Finished processing build request in 1m9.738923881s

Next, I dragged and dropped the public/ folder into the “site serving” feature on Netlify’s page which simply serves the static files. Same issue with the post missing, indicating the problem is not in Netlify (or so I am told.) The page looks the same as the Netlify deploy preview screenshot above. There is no build log since Netlify does not do the build.

The site serving feature is the box below my site:

I tried:

  • Changing the date forward and back, and testing with the -F flag.
  • Checked that it is not a draft, and explicitly labeled it with draft: false
  • Created another test post with the hugo new command and verified the same issue with it (shown in the above photos)
  • Checked the individual index.html files in the public folder to ensure the post(s) are properly linked

I have a bunch of screenshots (which I think would be helpful!) but I am not allowed to post them since I am new, so I will try to add them below.

I am out of ideas, so any help appreciated.

Screenshot of behavior on localhost

Screenshot from 2020-05-20 23-58-07

Screenshot of behavior (missing posts) in deploy preview on Netlify, and when dragging and dropping the public/ folder into Netlify’s site serving feature.

Screenshot from 2020-05-20 23-58-49

Are you sure that you are adding new content on the master branch of your repo?

Your post from the screenshot above is present only in the dev branch.

Typical Netlify deploys use the master branch.

Good question, and good point. Netlify is previewing the deploy of the dev branch, which contains the two new posts. However, even building the public folder locally (from the dev branch) and dragging and dropping it into the Netlify site builder (the screenshot in the first post) shows the posts as missing, even though they are in the public folder and appear to be linked correctly.

As per your site’s deploy logs the website was last deployed on May the 12th via commit edit about me · jsigee87/personal-website@04b6cec · GitHub

The content files you mention missing were not present in the above commit or in a prior one.

The more recent commits in your repo were made in the dev branch and only triggered deploy previews on Netlify.

As far as I can tell Netlify’s drag and drop functionality works only for new sites. Not ones that are are already connected with a Git remote:

Want to deploy a new site without connecting to Git?
Drag and drop your site folder here

I truly appreciate the help, but am not sure my previous posts are being understood correctly. I hope this can clarify things.

As per your site’s the website was last deployed on May the 12th via commit edit about me · jsigee87/personal-website@04b6cec · GitHub

This is correct, but not sure how it relates.

The more recent commits in your repo were made in the dev branch and only triggered deploy previews on Netlify.

Correct again (and I have stated this twice.) The issue I am seeking help with is that the deploy previews do not show the new posts made in the dev branch. I verified with Netlify’s drag and drop feature that the issue is not with the Netlify build process.

As far as I can tell Netlify’s drag and drop functionality works only for new sites.

I am not sure why you think I could not drag and drop my public folder into that feature. There is nothing in the documentation saying that your “new site” cannot look like one of your existing sites. Nothing is stopping me from creating as many versions of my site as I wish.

Since the Netlify drag and drop feature does no building of the site, this is how I have determined the issue is not with Netlify. Again, I have built my site locally (from the dev branch), dropped the public folder into the drag and drop feature to create a new site, and content is missing from the site that appears to exist in the public folder.

Not being a web developer, I am out of debugging tools. Do you have other suggestions on how to verify my changes are correct without deploying live to my site, or how to narrow down the problem further? Perhaps another static deployment tool that can verify whether it is an error in Netlify’s drag and drop tool? A way to verify my settings or linked content within the public folder?

Your website is already connected to a Git repo. It gets updated only when you push a commit from your local machine to the master branch of the remote.

Your website at https://www.johnsigmon.me/ will not be updated via Netlify’s folder upload because the domain is already connected through Git to an existing site. The upload feature will create a new site that will not be published to your domain.

If you wish to switch your workflow from Git to folder uploads then you need to first disconnect your existing Netlify site from your domain and then have it connected to the new site that will be generated via the folder upload.

Regarding your other questions about Netlify it would be best to ask them directly at their forum.

If you want to keep things as you have them setup right now I suggest that you familiarize yourself with the basics of Git.

You need to switch to the master branch on your local machine and then either merge the entire dev branch or cherry pick what you need from it. Then you need to make a new commit and push it to the remote on GitHub to update the website on Netlify.

I want to update after getting a friend to take a look with me, in case it helps others who find this post. We noticed that in the Netlify drag and drop and deploy previews, the home page renders correctly. After clicking on the writing tab or any other link, it changes my base URL to https://www.johnsigmon.me . By typing the necessary relative links after the “fake” Netlify URL, I was able to see the deploy preview:

As you can see in the photo above, the links are all relative so my understanding is that this should not occur. I’ll try to dig through the Hugo docs for any relevant config arguments next.

Regarding your last reply, this issue has nothing whatsoever to do with Git. Additionally, I am well versed with Git, and I don’t see any need to be patronizing. Additionally, as far as I can tell, this is an issue with linking in Hugo, not Netlify. Please correct me if I am wrong by pointing to documentation or behavior that shows otherwise.

I am certainly not patronizing anyone.

The above advice was based on what I saw in the GitHub repo, on Netlify and in the posts in this topic.

Also I fail to see why you do not simply update the master branch of your project.

Anyway perhaps someone else can help you.

Perhaps someone else can help me with my issue of Hugo not linking pages correctly! Surely it is reasonable to desire to preview a build before it is deployed to a live website (my actual issue all along!)

For anyone that came here for my actual concern, I have at least found the direction in which the solution lies, which I have stated above. I will update this post when I find the solution for anyone who may find this in the future.

I hope that for the sake of other posters on this forum you come back at some point to reread my posts. You may see that you have completely misunderstood my problem. I have never had any issue with deploying to my site via the master branch or any issues with git, and nothing here should have led you to believe that.

Right. So what you really meant all along was internal links to my posts do not work on the Netlify deploy preview

Guess what? You were not clear at all and I am not in the habit of chewing laurel leaves trying to guess what one means.

The baseURL value in the project config is the one that is used for all internal links.

Netlify deploy previews serve the site preview under another domain, hence the links do not work.

But I suppose that you can try setting relativeURLs to true in the project config and see if that helps.

1 Like

Oh, that’s a neat saying! I’m gonna look it up. :slight_smile:

Hiya! :wave: Please ask Netlify, your hosting company, what the deal is.

I think plenty of folks here might help, but their support can definitely help. It’s their service! So cool! You are golden with them, ne? :sunglasses:

1 Like

@maiki

Pythia, the priestess of the ancient oracle at Delphi supposedly went into a frenzied state and spoke the will of the god Apollo, after chewing on laurel leaves and inhaling fumes from a chasm.

Typically the priestess spoke gibberish and a body of other priests had the task of interpreting Pythia.

There is a record of supposed oracular statements by Pythia, famous (or infamous) for their double meaning.

For example

“You will go, return not die in the war”

The above is a response to an unknown person who wished to know whether it would be safe to join a military campaign. Here we see the ambiguity of Pythia’s phrasing of answers in all its splendid craftiness, making sure that her prediction is foolproof no matter what the outcome. Her answer above can have two entirely opposite meanings, depending on where a missing comma is supposed to be – before or after the word “not”. We are in awe of you great Pythia.

ref

1 Like

Hey, thanks for trying to help! Unfortunately, the issue is not with Netlify.

To avoid any other confusion I marked my above post as the solution.

To try to clarify one last time, my problem was:

It rendered fine in localhost after building with hugo and previewing with hugo server. I created a pull request from the dev branch in the repo which automates a deploy preview in Netlify. The post was missing.

The solution was to discover that Hugo is not using the relative links in the HTML, but instead clobbering the base url and providing the one in my config file. This was causing the behavior I saw because it would redirect to my baseurl (johnsigmon.me) which did not have the uploaded posts yet.

I have not yet had time to dig further into it to find out if this is a feature or a bug, but will open a new post or issue as appropriate when I have more details.

And naturally you arrived to the above conclusion all by yourself.

This topic has been a massive waste of time.

Before opening another topic in this forum do have a thorough look at the Requesting Help guidelines. It will save everybody’s time in the future.