I have some bullet points on my homepage that I would like to give specific styling to. I thought a reasonable approach would be to wrap a markdown link in a custom shortcode:
The shortcode is located in layouts/shortcodes/big_title.html:
<p id='test'>{{ .Inner }}</p>
And my custom style is in static/css/style.css:
#test{
color: blue;
font-weight: bold;
}
The styling works (the text is both blue and bold) but the text is incorrect and there is no link. This is the text that renders (in blue and bold): - [QUESTIONS](http://localhost:1313/questions/)
I have played around with all sorts but I just can’t seem to get this to work.
I should add that if I make a test with raw HTML in my markdown file (after setting unsafe = true in [markup.goldmark.renderer]):
<p id='test'>
<a href='/about'>TEST</a>
</p>
“TEST” renders as a functioning link but without styling.
Many thanks in advance for the support.
Disclaimer: I have a basic understanding of markdown, HTML and CSS (in decreasing order). I have spent a reasonable amount of time just processing simple .md files in Hugo and I am now attempting to build a basic theme of my own.
Sidenote:
I’ve read and reread several sections of the Hugo docs but I’m just not seeing a clear path towards steadily learning the power of Hugo and applying it. If anyone has a particular resource they could recommend it’d be much appreciated.
If you’re going to include raw HTML in your Markdown, as you have done within your shortcode template, you need to be aware of the rules as described in the CommonMark specification.
Technically you don’t need the blank line above the template action because, with your example, .Inner has a leading newline, but it’s good to get into the habit of doing so.
Thank you. However, though your suggestion has fixed the text rendering, the styling is now gone.
Please note that I am using Hugo extended version 0.130. If you think that updating Hugo will solve this issue, I’ll gladly do so. I just suspect that it’s probably just me making a mistake somewhere.
I guess I don’t understand what you’re trying to do.
Are you trying to place a paragraph within a list item, or are you trying to wrap an entire list within a paragraph? The latter is invalid per the HTML spec.
Do you want to style the a element or the li element?
Do you want all of them within the ul element styled the same way?
Is the styling global or only for a particular list?
For now, I would say that I am just trying to style the a element. I would like to eventually have an <ul> element with the same style applied to all <li> elements within it. I have no answer on the global/local styling yet since I’m just testing a few things so I can get my bearings and see how I might start building my own theme.
If you could, please take note of my earlier point about raw HTML in my markdown file (without a shortcode) also not receiving the styling. Although I started off thinking the issue was with the shortcode, I no long think this is the case. I’ll add a bit more detail:
Putting this straight into my markdown file works:
<p id='test'>TEST</p>
The id is picked up my my css file and the styling is applied.
This does not work: (the wrapping in the <p> element with an id is what I initially tried to use a shortcode for)