Import a Markdownfile with external links in Hugo

I would like to insert the automatically created in /content/en/ This works so far, only the horizontal line in the h2 header is not imported. On the other pages, this line is also not displayed in the h1 header and h2 header. I would like the, which is located in the root directory, to be displayed with the horizontal line. Can the line be inserted into the page via the frontmatter? What should the shortcode include.html look like?

2nd question: The Hugo website will run on GitLab Pages. The links work fine in Gitlab itself. The links in the /content/en/ have to be rewritten.

Here is an urlPatternCommit = '' from @jomooring. This could be an idea?

## 0.0.1 (2024-05-30)

### FIX: Delete (1 change)

- [FIX: Delete](username/developer@5934b6c87abb7e84b50ad7c38f78b48e7b4391a4)

The link should be overwritten from:

- [FIX: Delete](username/developer@5934b6c87abb7e84b50ad7c38f78b48e7b4391a4)


{{ $file := .Get 0 }}
{{ $file | readFile | safeHTML }}

in content/en/

title: "Changelog"
  disableGitLabEditLink: true
description: "Changelog"
draft: false
slug: changelog
        weight: 2

{{< row >}}
{{< column col-md-12 >}}
{{< include "" >}}
{{< /column >}}
{{< /row >}}


  - prepare
  - release

  stage: prepare
  - if: '$CI_COMMIT_TAG =~ /^v?\d+\.\d+\.\d+$/'
    - 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=$CI_COMMIT_TAG" | jq -r .notes >'
    - 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN" -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=$CI_COMMIT_TAG"'
    - cat

  stage: release
    - job: prepare_job
      artifacts: true
  - if: '$CI_COMMIT_TAG =~ /^v?\d+\.\d+\.\d+$/'
    - echo "Creating release"
    name: 'Release $CI_COMMIT_TAG'
    tag_name: '$CI_COMMIT_TAG'
    ref: '$CI_COMMIT_SHA'
        - name: 'Container Image $CI_COMMIT_TAG'

I doubt that the MD file contains a horizontal line at all.

Use CSS for styling, perhaps setting an appropriate border-bottom property for your headings.

Markdown automatically creates a horizontal line for h1 and h2 headers. Hugo does not display this line. I only want this line to be displayed in /content/en/

Here is the original file from GitLab.

Here is the file after the import into Hugo:

That is not an „original“ MD file. It’s rendered as HTML. Which is styled using CSS.

Have a look at the MD source.

Also, Hugo does not display markdown. It converts it to HTML. Which is then styled with CSS.

1 Like

I would guess the md file contains a hr tag and your final html has a comment inside “raw html omitted”

More details here:

For the link you might need to implement your own link render hook taking care of the gitlab links

Well, that’s a possibility. But the OP doesn’t show us the source. What I found online (angular/ at main · angular/angular · GitHub) certainly does not include a hr element.

And there’s the minimum CSS here

which uses a border-bottom. It’s all about CSS.


I have added the source code. I don’t know how to include the <hr> in the shortcodes. I have added the source code. I don’t know how to include the <hr> in the shortcodes.

I told you already. There is no hr element. Nowhere. Use CSS and border-bottom.

And this is not related to Hugo, not even remotely. There are tons of sources on the Net regarding HTML and CSS.

Here is my css. Now all h2 headings have a line. That is not what I want. I only want the changelog file to have the new h2 heading. How do I do this correctly?

h2 {
	font-size: 1.5em;
	font-weight: 600;
	margin: 24px 0 16px;
	padding-bottom: .3em;
	border-bottom: 1px solid #bfbfc3;
	color: #333238;

That’s still not on-topic here.

It’s a real shame that you don’t want to answer what you consider to be a simple question.

I don’t want to diene any more time on your problem, which is still not on-topic here. That’s all.

You can use markdown attributes.


.bb {
  border-bottom: 1px solid #bfbfc3;


## Section 1


## Section 2 {.bb}


The second h2 element will have a bottom border.

If you can’t modify the file, you’ll have to add a class to the body element in order to target the page with a CSS selector. Something like…

{{ $classes := printf "type-%s kind-%s path-%s" .Type .Kind (anchorize .Path) }}
<body class="{{ $classes }}">

When you view http://localhost:1313/foo/changelog/ it looks like:

<body class="type-foo kind-page path-foochangelog">

Then in your CSS you can do this:

.path-foochangelog h2 {
  border-bottom: 1px solid #bfbfc3;

Obvioulsy, this will break if you later decide to move or rename the changelog file.

Thank you for your help. Great solution.

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