mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-24 21:56:05 +02:00
Add a BlackFriday option for rel="nofollow" on external links
Add a configuration option "nofollowLinks". When set to "true" the "HTML_NOFOLLOW_LINKS" flag is being passed to Blackfriday. Thereby all *absolute* links will get a "nofollow" value for the "rel" attribute. Fixes #4722
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
d68367cbe7
commit
7a6192647a
@@ -108,6 +108,7 @@ type BlackFriday struct {
|
||||
AngledQuotes bool
|
||||
Fractions bool
|
||||
HrefTargetBlank bool
|
||||
NofollowLinks bool
|
||||
SmartDashes bool
|
||||
LatexDashes bool
|
||||
TaskLists bool
|
||||
@@ -124,6 +125,7 @@ func newBlackfriday(config map[string]interface{}) *BlackFriday {
|
||||
"smartypantsQuotesNBSP": false,
|
||||
"fractions": true,
|
||||
"hrefTargetBlank": false,
|
||||
"nofollowLinks": false,
|
||||
"smartDashes": true,
|
||||
"latexDashes": true,
|
||||
"plainIDAnchors": true,
|
||||
@@ -277,6 +279,10 @@ func (c *ContentSpec) getHTMLRenderer(defaultFlags int, ctx *RenderingContext) b
|
||||
htmlFlags |= blackfriday.HTML_HREF_TARGET_BLANK
|
||||
}
|
||||
|
||||
if ctx.Config.NofollowLinks {
|
||||
htmlFlags |= blackfriday.HTML_NOFOLLOW_LINKS
|
||||
}
|
||||
|
||||
if ctx.Config.SmartDashes {
|
||||
htmlFlags |= blackfriday.HTML_SMARTYPANTS_DASHES
|
||||
}
|
||||
|
Reference in New Issue
Block a user