When I set the Baseurl to "/", the name of the blog will link to the original page and will not go to the root directory of the blog

My Blog link: https://charle00001.github.io/

When I set “baseURL” to “/” in the config file (/config/hugo.yaml), my blog will report an error:

macOS:charle00001s_Blog charlie$ 
macOS:charle00001s_Blog charlie$ hugo
Start building sites … 
hugo v0.121.1-00b46fed8e47f7bb0a85d7cfc2d9f1356379b740+extended darwin/amd64 BuildDate=2023-12-08T08:47:45Z VendorInfo=brew

ERROR failed to process "/paperfile/friends/index.html": "/var/folders/n7/v73ttgc104db0znkqs25nyxc0000gn/T/hugo-transform-error1606948317:72:40": expected comma character or an array or object ending on line 72 and column 40
   12:     {
           ^
ERROR failed to process "/paperfile/games_about/index.html": "/var/folders/n7/v73ttgc104db0znkqs25nyxc0000gn/T/hugo-transform-error3885114872:72:40": expected comma character or an array or object ending on line 72 and column 40
   12:     {
           ^
ERROR failed to process "/paperfile/get-vpn/index.html": "/var/folders/n7/v73ttgc104db0znkqs25nyxc0000gn/T/hugo-transform-error51556661:72:40": expected comma character or an array or object ending on line 72 and column 40
   12:     {
           ^
ERROR failed to process "/paperfile/get-network-breaking-software/index.html": "/var/folders/n7/v73ttgc104db0znkqs25nyxc0000gn/T/hugo-transform-error3527982379:72:40": expected comma character or an array or object ending on line 72 and column 40
   12:     {
           ^
Total in 3636 ms
Error: error building site: render: failed to render pages: failed to process "/paperfile/btc/index.html": "/var/folders/n7/v73ttgc104db0znkqs25nyxc0000gn/T/hugo-transform-error1627656448:72:40": expected comma character or an array or object ending on line 72 and column 40
   12:     {
           ^
macOS:charle00001s_Blog charlie$ 

And I set “baseURL” to blank, the error disappered.

But I cannot go to home when I’m on a page not home.

When I click the title of my blog, I will stop on the original page (for example, I am in a post, and I click the title of the blog, and it doesn’t work, I want to go to the home page)

And when I click the top bar, I will go to 404 page:

For example, I am in a post, link example.com/post/1,

Now I click a button link in the top bar, original link is example.com/button/1, this is corrct;

But I go to: example.com/post/1/button/1, this is wrong.

How can I fix it?

My config file:

baseURL: /
# baseURL: "https://charle00001.github.io/"
title: Charle00001`s Blog
paginate: 7
theme: PaperMod
disableHugoGeneratorInject: true

hasCJKLanguage: true 
defaultContentLanguage: zh
defaultContentLanguageInSubdir: false

# 多语言模式
# languages:
#   en:
#     disabled: false
#     contentDir: content/
#     languageCode: "en-US"
#     languageDirection: ""
#     languageName: "English"
#     title: "Charle00001`s Blog"
#     weight: 0
#   zh:
#     disabled: false
#     languageCode: "zh-CN"
#     languageDirection: ""
#     languageName: "Chinese"
#     title: "Charle00001的博客"
#     weight: 1

enableRobotsTXT: true
buildDrafts: false
buildFuture: false
buildExpired: false

googleAnalytics: UA-123-45

minify:
  disableXML: false
  minifyOutput: true

params:
  env: production # to enable google analytics, opengraph, twitter-cards and schema.
  title: Charle00001`s Blog
  description: "编程、折腾、博客,随便吧.只要活的开心就行!本人会不定期写博客,因为不会用搜索引擎收录工具,所以没人看=(. 会继续努力💪的!Hugo, Hexo, papermod, golang, Charle00001的博客"
  keywords: [Charle00001, Charle00001的博客, Charle00001's blog, Hugo, papermod, golang, shell, bash, hexo, js, html, markdown, english, 英语, student, blog, next]
  author: Charle00001
  # author: ["Me", "You"] # multiple authors
  images: ["<link or path of image for opengraph, twitter-cards>"]
  DateFormat: "January 2, 2006"
  defaultTheme: dark # dark, light, auto
  disableThemeToggle: false

  ShowReadingTime: true
  ShowShareButtons: true
  ShareButtons: []
  ShowPostNavLinks: true
  ShowBreadCrumbs: true
  ShowCodeCopyButtons: true
  ShowWordCount: true
  ShowRssButtonInSectionTermList: true
  ShowAllPagesInArchive: true
  UseHugoToc: true
  disableSpecial1stPost: false
  disableScrollToTop: false
  comments: true
  hidemeta: false
  hideFooter: false
  hideSummary: false
  showtoc: true
  tocopen: false

  assets:
    disableHLJS: false # to enable highlight.js
    disableFingerprinting: false
    favicon: "/images/icon/favicon.ico"
    favicon16x16: "/images/icon/favicon-16x16.png"
    favicon32x32: "/images/icon/favicon-32x32.png"
    apple_touch_icon: "/images/icon/apple-touch-icon.png"
    safari_pinned_tab: "/images/icon/apple-touch-icon.png"

  label:
    text: "Charle00001`s Blog"
    icon: /images/icon/happy.png
    iconHeight: 35

  # profile-mode
  profileMode:
    enabled: false # needs to be explicitly set
    title: ExampleSite
    subtitle: "This is subtitle"
    imageUrl: "<img location>"
    imageWidth: 120
    imageHeight: 120
    imageTitle: my image
    buttons:
      - name: Posts
        url: posts
      - name: Tags
        url: tags

  # home-info mode
  homeInfoParams:
    Title: "Hi there | 你们好鸭"
    Content: "Welcome :) 欢迎"

  socialIcons:
    - name: link
      url: "/"
    - name: email
      url: "mailto:charle00001@proton.me"
    - name: github
      url: "https://github.com/charle00001"
    - name: bitcoin
      url: "/paperfile/btc/"

  analytics:
    google:
      SiteVerificationTag: "XYZabc"
    bing:
      SiteVerificationTag: "XYZabc"
    yandex:
      SiteVerificationTag: "XYZabc"

  cover:
    hidden: true # hide everywhere but not in structured data
    hiddenInList: true # hide on list pages and home
    hiddenInSingle: true # hide on single page

  editPost:
    URL: "https://example.com"
    Text: "暂不支持编辑文章" # edit text
    appendFilePath: false # to append file path to Edit link

  # for search
  # https://fusejs.io/api/options.html
  fuseOpts:
    isCaseSensitive: false
    shouldSort: true
    includeMatches: true
    includeScore: 1
    location: 0
    distance: 1000
    threshold: 0.1
    minMatchCharLength: 2
    keys: ["title", "permalink", "summary", "content"]

# 顶栏设置
menu:
  main:
    - name: 关于
      url: paperfile/about/
      weight: 10
    - name: 推荐
      url: /paperfile/my-own-fav-posts-page/
      weight: 20
    - name: 归档
      url: /paperfile/archives/
      weight: 30
    - name: 友情链接
      url: /paperfile/friends/
      weight: 40
    - name: 留言板
      url: /paperfile/lyb/
      weight: 50
    - name: 别的&工具
      url: /paperfile/other-and-tools
      weight: 60
    - name: 搜索
      url: /search/
      weight: 70
# Read: https://github.com/adityatelange/hugo-PaperMod/wiki/FAQs#using-hugos-syntax-highlighter-chroma
pygmentsUseClasses: true

# Goldmark 配置
markup:
  goldmark:
    extensions:
      cjk:
        eastAsianLineBreaks: true
        eastAsianLineBreaksStyle: simple
        enable: true
        escapedSpace: true
      definitionList: true
      footnote: true
      linkify: true
      linkifyProtocol: https
      strikethrough: true
      table: true
      taskList: true
      typographer:
        apostrophe: '&rsquo;'
        disable: false
        ellipsis: '&hellip;'
        emDash: '&mdash;'
        enDash: '&ndash;'
        leftAngleQuote: '&laquo;'
        leftDoubleQuote: '&ldquo;'
        leftSingleQuote: '&lsquo;'
        rightAngleQuote: '&raquo;'
        rightDoubleQuote: '&rdquo;'
        rightSingleQuote: '&rsquo;'
    parser:
      attribute:
        block: false
        title: true
      autoHeadingID: true
      autoHeadingIDType: github
      wrapStandAloneImageWithinParagraph: true
    renderer:
      hardWraps: false
      unsafe: true
      xhtml: false

  highlight:
    noClasses: false
    # anchorLineNos: true
    # codeFences: true
    # guessSyntax: true
    # lineNos: true
    # style: monokai

outputs:
  home:
    - HTML
    - RSS
    - JSON

taxonomies:
   tag: tags
   category: categories

(sorry, my English is bad)

Neither "/" nor "" is a valid baseURL value.

See https://gohugo.io/getting-started/configuration/#baseurl

If you need additional assistance, please share a link to the public repository for your project’s source files. See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

1 Like

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