URLs broken on all content

Why is the base url being preprended to the url I provide to url_slides? For instance, let’s say I’m at my site page here: STAT 5170: Applied Time Series | Taylor R. Brown

It is referencing the following config file content/courses/5170/index.md :

---
title: "STAT 5170: Applied Time Series"
date: 2020-07-19
url_slides: "https://github.com/tbrown122387/stat_5170_slides"
---

Feel free to message me directly for other types of materials.

But you can see, when you go to that site, and click on the “slides” button, the link is all broken. It refers you to the nonexistent https://tbrown122387.github.io/https:/github.com/tbrown122387/stat_5170_slides

The first part of that is my base url in config/_default/config.toml So hey, why not change base url to baseurl = “” That doesn’t work though. I’ve also tried baseURL = “” No luck.

What’s the deal here?

I can replace the link with something like [slides]( https://github.com/tbrown122387/stat_5170_slides)but the button doesn’t look as cool.

Can you share your config.toml file with us?

Sure, thanks for the response. Here it is:

# Configuration of Hugo
# Guide: https://sourcethemes.com/academic/docs/get-started/
# Hugo Documentation: https://gohugo.io/getting-started/configuration/#all-configuration-settings
#
# This file is formatted using TOML syntax - learn more at https://learnxinyminutes.com/docs/toml/
# Each configuration section is defined by a name in square brackets (e.g. `[outputs]`).

# Title of your site
title = "Taylor R. Brown"

# The URL of your site.
# End your URL with a `/` trailing slash, e.g. `https://example.com/`.
#baseurl = "http://people.virginia.edu/~trb5me/"
#baseurl = "https://tbrown122387.github.io/"
#baseurl = ""
baseURL = ""
# Enter a copyright notice to display in the site footer.
# To display a copyright symbol, type `©`. For current year, type `{year}`.
copyright = ""

#https://gohugo.io/content-management/urls/
# was having difficulty writing links in .md files for content
uglyurls = true

############################
## Advanced options below ##
############################

# Get last modified date for content from Git?
enableGitInfo = true

# Default language to use (if you setup multilingual support)
defaultContentLanguage = "en"
hasCJKLanguage = false  # Set `true` for Chinese/Japanese/Korean languages.
defaultContentLanguageInSubdir = false
removePathAccents = true  # Workaround for https://github.com/gohugoio/hugo/issues/5687

summaryLength = 30  # Listing summary length in words. Also, see `abstract_length` in `params.toml`.
paginate = 10  # Number of items per page in paginated lists.
enableEmoji = true
enableRobotsTXT = true
footnotereturnlinkcontents = "<sup>^</sup>"
ignoreFiles = ["\\.ipynb$", ".ipynb_checkpoints$", "\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$"]

# Workaround Hugo publishing taxonomy URLs as plurals - consistently use singular across Academic.
[permalinks]
  authors = "/author/:slug/"
  tags = "/tag/:slug/"
  categories = "/category/:slug/"
  publication_types = "/publication-type/:slug/"

[outputs]
  home = [ "HTML", "RSS", "JSON", "WebAppManifest" ]
  section = [ "HTML", "RSS" ]

[mediaTypes."application/manifest+json"]
  suffixes = ["webmanifest"]

[outputFormats.WebAppManifest]
  mediaType = "application/manifest+json"
  rel = "manifest"

# Configure the Markdown renderer.
[markup]
  defaultMarkdownHandler = "goldmark"
  [markup.goldmark]
    [markup.goldmark.renderer]
      unsafe = true  # Enable user to embed HTML snippets in Markdown content.
  [markup.highlight]
    codeFences = false  # Disable Hugo's code highlighter as it conflicts with Academic's highligher.
  [markup.tableOfContents]
    startLevel = 2
    endLevel = 3

[imaging]
  resampleFilter = "lanczos"
  quality = 90
  anchor = "smart"  # Anchor for cropping. Options include Smart and Center.

# Taxonomies.
[taxonomies]
  tag = "tags"
  category = "categories"
  publication_type = "publication_types"
  author = "authors"

# Related content.
[related]
  threshold = 80.0
  includeNewer = true
  toLower = true

  [[related.indices]]
    name = "title"
    weight = 60.0

  [[related.indices]]
    name = "summary"
    weight = 50.0

  [[related.indices]]
    name = "tags"
    weight = 80.0

  [[related.indices]]
    name = "categories"
    weight = 70.0

  [[related.indices]]
    name = "authors"
    weight = 20.0

# Install Wowchemy
[module]
  [[module.imports]]
    path = "github.com/wowchemy/wowchemy-hugo-modules/wowchemy"
  [[module.imports]]
    path = "github.com/wowchemy/wowchemy-hugo-modules/netlify-cms-academic"

Please post the layout, that is transforming the url_slides frontmatter. There is probably something like absURL in there that will prepend the baseURL to the link.

What is the “layout?” Is that a file somewhere?

Yes :). Well… the best would be if you put your repository public for a bit so we can look into it. It does not sound like there is an easier way to find your issue.

Everything is available here: GitHub - tbrown122387/my_academic_site_v2: my website

This repo was last updated 27 days ago. Please push the changes from your local repo.

Done. If you see the latest commit though it only has my attempted fixes

Try this:

mkdir ~/temp
cd ~/temp
git clone --recurse-submodules https://github.com/tbrown122387/my_academic_site_v2
cd my_academic_site_v2
git revert --no-edit d894070
hugo server

Then browse to http://localhost:1313/courses/5170/.

When I do this I see a “Slides” button which links to https://github.com/tbrown122387/stat_5170_slides.

So, all looks well. Or I don’t understand the problem.

You’re right, that looks fine when you preview it like that. I guess the problem must be related to how I push the public/ folder to my github io site.

This is usually how I do it:

cd ~/my_academic_site_v2/
hugo
sudo cp -r public/* ~/tbrown122387.github.io/
cd ~/tbrown122387.github.io/
git add .
git commit -m "yadayadayada"
git push origin main

Look at this:
https://github.com/tbrown122387/tbrown122387.github.io/blob/main/courses/5170/index.html#L795

Note the leading / in the href attribute:

href="/https:/github.com/tbrown122387/stat_5170_slides"

Let me suggest the following:

  1. Delete your public folder
  2. Set baseurl to https://tbrown122387.github.io/
  3. Commit and push your changes.
  4. Rebuild the site using the steps in your last post.
1 Like

Hey now, it works! thanks! That fixed it.

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