When I use baseURL as local host, all of my links still link to the served version on my website

Hi all, I have hosting my website on GitHub with my own domain. I wanted to be able to run the website locally to see changes as I make them. However, when I change the baseURL to http://localhost:54586/ for example, all the other links on the website still points to my domain url so it all goes to the hosted website. You can see in the image when I search for my domain, that my domain name still shows up everywhere. The homepage takes me to the local one but once I click any link on the page, im back in hosted version. Any help appreciated !

In the toml :

baseURL = “http://localhost:54586/” # Replace with your domain
languageCode = “en-us”
title = “udesh”
theme = “PaperMod”
summaryLength = 50
paginate = 10

Set the baseURL to the URL from which your production site will be served. Hugo replaces that value internally when you run hugo server — you don’t have to change anything.

2 Likes

I’ve tried that but doesn’t work :frowning:

Pasting my toml

baseURL = "https://udesh.io" # Replace with your domain
languageCode = "en-us"
title = "udesh"
theme = "PaperMod"
summaryLength = 50
paginate = 10

# Author information
[author]
  name = "Udesh"
  website = "https://udesh.io"

# Menu Configuration
[menu]

  [[menu.main]]
    identifier = "home"
    name = "home"
    url = "/"
    weight = 1

  [[menu.main]]
    identifier = "podcast"
    name = "podcast"
    url = "/podcast/"
    weight = 2

  [[menu.main]]
    identifier = "personal"
    name = "writing/personal"
    url = "/personal/"
    weight = 3

  [[menu.main]]
    identifier = "academic"
    name = "writing/academic"
    url = "/academic/"
    weight = 4

  [[menu.main]]
    identifier = "misc"
    name = "misc."
    url = "/misc/"
    weight = 5

# Parameters for the PaperMod theme
[params]

  logo = "images/logo.png" # Add a logo in your "static/images" directory
  themeColor = "#FF370C" # Customize to match your preferred brand color
  mode = "light" # Options: "light", "dark", "auto"
  customCSS = ["css/extended/tufte.css"]

  ShowReadingTime = true # Display estimated reading time for posts
  ShowShareButtons = false # Enable sharing buttons on posts
  ShowBreadCrumbs = false
  ShowProjectsPage = false # Add this line to disable showing projects on the homepage
  mainSections = ["posts", "essays"]
  disableThemeToggle = true

Looks like there is something in your site setup.

According to the docs menus should use the pageRef property for internal links and url for external ones.

If that does not help we’ll be faster if you could
share your repo to have a look.

hugo server for me always works like described.
Which hugo version?

Thanks for the help! I tried that but no beuno :frowning:
Version : hugo v0.135.0+extended darwin/arm64 BuildDate=2024-09-27T13:17:08Z VendorInfo=brew

here is the repo

I also get these warnings when hugo server if it matters:

WARN  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  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  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  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  found no layout file for "html" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

That matters, it tells you you have no layout for home and page that way no pages are recreated but the content of your public folder stays as it is.

  • there’s something wrong with your local submodule import of the papermod theme.

  • check the status git submodule status

    a2eb47bb4b805116dcd34c1605d39835121f8dbe themes/PaperMod (v7.0-119-ga2eb47b)
    
  • update the submodule

    git submodule update
    

I’m not able to reproduce your problem using your repository. What I did

git clone https://github.com/onedeeper/mysite --recurse-submodules
Cloning into 'mysite'...
remote: Enumerating objects: 396, done.
remote: Counting objects: 100% (396/396), done.
remote: Compressing objects: 100% (126/126), done.
remote: Total 396 (delta 197), reused 381 (delta 182), pack-reused 0 (from 0)
Receiving objects: 100% (396/396), 824.96 KiB | 1.78 MiB/s, done.
Resolving deltas: 100% (197/197), done.
Submodule 'themes/PaperMod' (https://github.com/adityatelange/hugo-PaperMod.git) 
registered for path 'themes/PaperMod'
Cloning into 'C:/_repos/github/clone/mysite/themes/PaperMod'...
remote: Enumerating objects: 7462, done.
remote: Counting objects: 100% (40/40), done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 7462 (delta 11), reused 21 (delta 4), pack-reused 7422 (from 1)
Receiving objects: 100% (7462/7462), 9.38 MiB | 1.70 MiB/s, done.
Resolving deltas: 100% (4410/4410), done.
Submodule path 'themes/PaperMod': checked out 'a2eb47bb4b805116dcd34c1605d39835121f8dbe'
hugo server
WARN  deprecated: site config key paginate was deprecated in Hugo v0.128.0 and will be 
removed in a future release. Use pagination.pagerSize instead.
Watching for changes in C:\_repos\github\clone\mysite {archetypes,assets,content,layouts,static,themes}
Watching for config changes in C:\_repos\github\clone\mysite\hugo.toml
Start building sites …
hugo v0.135.0-f30603c47f5205e30ef83c70419f57d7eb7175ab+extended windows/amd64 BuildDate=2024-09-27T13:17:08Z VendorInfo=gohugoio

WARN  deprecated: .Site.Author was deprecated in Hugo v0.124.0 and will be removed in a 
future release. Use taxonomies instead.
WARN  The author key in site configuration is deprecated. Use params.author.name instead.

                 | EN
-------------------+-----
Pages            | 21
Paginator pages  |  0
Non-page files   |  0
Static files     | 20
Processed images |  0
Aliases          |  7
Cleaned          |  0

Built in 43 ms
Environment: "development"
Serving pages from disk
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
here's the result of the generated home page:
<!DOCTYPE html>
<html lang="en" dir="auto">

<head>
	<meta name="generator" content="Hugo 0.135.0"><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script><meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="robots" content="noindex, nofollow">
<title>udesh</title>

<meta name="description" content="">
<meta name="author" content="">
<link rel="canonical" href="http://localhost:1313/">
<link crossorigin="anonymous" href="/assets/css/stylesheet.01e04f4f86ae4dc2260171c32fa67a7e225672ca47849727998e24982bc3323a.css" integrity="sha256-AeBPT4auTcImAXHDL6Z6fiJWcspHhJcnmY4kmCvDMjo=" rel="preload stylesheet" as="style">
<link rel="icon" href="http://localhost:1313/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="http://localhost:1313/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="http://localhost:1313/favicon-32x32.png">
<link rel="apple-touch-icon" href="http://localhost:1313/apple-touch-icon.png">
<link rel="mask-icon" href="http://localhost:1313/safari-pinned-tab.svg">
<meta name="theme-color" content="#2e2e33">
<meta name="msapplication-TileColor" content="#2e2e33">
<link rel="alternate" type="application/rss+xml" href="http://localhost:1313/index.xml">
<link rel="alternate" hreflang="en" href="http://localhost:1313/">
<noscript>
    <style>
        #theme-toggle,
        .top-link {
            display: none;
        }

    </style>
    <style>
        @media (prefers-color-scheme: dark) {
            :root {
                --theme: rgb(29, 30, 32);
                --entry: rgb(46, 46, 51);
                --primary: rgb(218, 218, 219);
                --secondary: rgb(155, 156, 157);
                --tertiary: rgb(65, 66, 68);
                --content: rgb(196, 196, 197);
                --code-block-bg: rgb(46, 46, 51);
                --code-bg: rgb(55, 56, 62);
                --border: rgb(51, 51, 51);
            }

            .list {
                background: var(--theme);
            }

            .list:not(.dark)::-webkit-scrollbar-track {
                background: 0 0;
            }

            .list:not(.dark)::-webkit-scrollbar-thumb {
                border-color: var(--theme);
            }
        }

    </style>
</noscript>
</head>

<body class="list" id="top">
<script>
    if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
        document.body.classList.add('dark');
    }

</script>

<header class="header">
    <nav class="nav">
        <div class="logo">
            <a href="http://localhost:1313/" accesskey="h" title="udesh (Alt + H)">udesh</a>
            <div class="logo-switches">
            </div>
        </div>
        <ul id="menu">
            <li>
                <a href="http://localhost:1313/" title="home">
                    <span class="active">home</span>
                </a>
            </li>
            <li>
                <a href="http://localhost:1313/podcast/" title="podcast">
                    <span>podcast</span>
                </a>
            </li>
            <li>
                <a href="http://localhost:1313/personal/" title="writing/personal">
                    <span>writing/personal</span>
                </a>
            </li>
            <li>
                <a href="http://localhost:1313/academic/" title="writing/academic">
                    <span>writing/academic</span>
                </a>
            </li>
            <li>
                <a href="http://localhost:1313/misc/" title="misc.">
                    <span>misc.</span>
                </a>
            </li>
        </ul>
    </nav>
</header>
<main class="main"> 
<div class="post-content"><p>I&rsquo;m Udesh Habaraduwa.<br>
I believe humanity is good, valuable, and worth saving.<br>
I believe in the power of reason and science but worship neither.<br>
I believe problems are inevitable, solvable, and worth solving.<br>
I believe that, all else being equal, it&rsquo;s better to be free.</p>
<hr>
<p><strong>Note</strong>: This site is under construction. I am working on bringing my work, currently unorganized, into this space. Meanwhile, you can check out:</p>
<ul>
<li>My <a href="https://onedeeper.substack.com">podcast</a>.</li>
<li>My <a href="https://www.linkedin.com/in/onedeeper/">LinkedIn</a>.</li>
<li>My <a href="https://github.com/onedeeper">GitHub</a>.</li>
</ul>
<p>Thank you for your patience!</p>


</div>
    </main>
    
<footer class="footer">
        <span>&copy; 2024 <a href="http://localhost:1313/">udesh</a></span> · 

    <span>
        Powered by
        <a href="https://gohugo.io/" rel="noopener noreferrer" target="_blank">Hugo</a> &
        <a href="https://github.com/adityatelange/hugo-PaperMod/" rel="noopener" target="_blank">PaperMod</a>
    </span>
</footer>
<a href="#top" aria-label="go to top" title="Go to Top (Alt + G)" class="top-link" id="top-link" accesskey="g">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 6" fill="currentColor">
        <path d="M12 6H0l6-6z" />
    </svg>
</a>

<script>
    let menu = document.getElementById('menu')
    if (menu) {
        menu.scrollLeft = localStorage.getItem("menu-scroll-position");
        menu.onscroll = function () {
            localStorage.setItem("menu-scroll-position", menu.scrollLeft);
        }
    }

    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener("click", function (e) {
            e.preventDefault();
            var id = this.getAttribute("href").substr(1);
            if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
                document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
                    behavior: "smooth"
                });
            } else {
                document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView();
            }
            if (id === "top") {
                history.replaceState(null, null, " ");
            } else {
                history.pushState(null, null, `#${id}`);
            }
        });
    });

</script>
<script>
    var mybutton = document.getElementById("top-link");
    window.onscroll = function () {
        if (document.body.scrollTop > 800 || document.documentElement.scrollTop > 800) {
            mybutton.style.visibility = "visible";
            mybutton.style.opacity = "1";
        } else {
            mybutton.style.visibility = "hidden";
            mybutton.style.opacity = "0";
        }
    };

</script>
</body>

</html>

You committed your public folder.

This contains old build files with the productive URL. As by before with the themes not working properly, there are no new pages generated/updated.

There’s (in most cases) no good reason to commit that. Better use a workflow, like this one from the docs Host on GitHub Pages | Hugo

If you really want to use and commit your locally generated public folder, you could use Static HTML By GitHub Actions

  • make sure you have a clean public folder before building (hugo won’t delete files there, just add/update)
  • test your site locally with hugo server
  • make sure you have no oild stuff in public
  • recreate the final version with just hugo and commit.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.