Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description element trimmed improperly #10

Open
mthu opened this issue Jul 19, 2018 · 4 comments
Open

Description element trimmed improperly #10

mthu opened this issue Jul 19, 2018 · 4 comments

Comments

@mthu
Copy link

mthu commented Jul 19, 2018

Hi, at following line, ltrim function is called improperly. The second argument is a set of characters, not a string prefix, so it does not strip the whole title from the beginning of the abstract as probably expected but it can strip more than that.
https://github.com/LotarProject/dokuwiki-plugin-semantic/blob/3d4d0233fdf169fb393884ee80cf68fc9b95294f/helper.php#L83

This leads to bad behavior. For example, having:
Abstract: "Adding a LDAP directory as a contact source for Thunderbird can be quite tricky .... "
Title: "Thunderbird LDAP via SSL with self-signed certificate"
is leading to output: "ory as a contact source for Thunderbird can be quite tricky ...."

In my Dokuwiki instance, the abstract is not prefixed with the page title, so no stripping is needed. Instead, something like this works for me (use title if no abstract is present):

public function getDescription() {
    return (@$this->meta['description']['abstract'] ? $this->meta['description']['abstract']: $this->getTitle());
}
@giterlizzi
Copy link
Owner

Hi @mthu,
thanks for your patch ;)

Fixed!

At your disposal,
Joseph

@jcamp
Copy link

jcamp commented Aug 20, 2018

I've looked at this and it seems to take the heading of the page and just the first 250 or 500 characters with \n (line breaks) which do not render well with Google SERP.

I suggest replacing the line breaks with Full Stops (.) and a space character. Which would make things read a lot better.

@jcamp
Copy link

jcamp commented Aug 20, 2018

Just for interest my code for that is:

public function getDescription() {
return (@$this->meta['description']['abstract'] ? str_replace("\n\n",". ",$this->meta['description']['abstract']): $this->getTitle());
}

@jcamp
Copy link

jcamp commented Aug 20, 2018

Which looks like this when checked in google semantic checker:

image

@giterlizzi giterlizzi reopened this Aug 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants